Python程序打印1到100之间的Pronic数

编写一个Python程序,使用while循环从1到100或在一个范围内打印Pronic数。此示例接受最小值和最大值,并显示该范围内的Pronic数。

def checkPronic(Number):
    i = 0
    flag = 0
    while i <= Number:
        if Number == i * (i + 1):
            flag = 1
            break
        i = i + 1
    return flag

minPro = int(input("Enter the Minimum Pronic Number = "))
maxPro = int(input("Enter the Maximum Pronic Number = "))

print("\nThe List of Pronic Numbers from {0} and {1}".format(minPro, maxPro)) 
for i in range(minPro, maxPro):
    if(checkPronic(i) == 1):
        print(i, end = '   ')
Python Program to Print Pronic Numbers from 1 to 100

使用for循环打印1到n的Pronic数的Python 程序

def checkPronic(Number):
    flag = 0
    for i in range(Number + 1):
        if Number == i * (i + 1):
            flag = 1
            break
    return flag

minPro = int(input("Enter the Minimum = "))
maxPro = int(input("Enter the Maximum = "))

print("\nThe List of Pronic Numbers from {0} and {1}".format(minPro, maxPro)) 
for i in range(minPro, maxPro):
    if(checkPronic(i) == 1):
        print(i, end = '   ')
Enter the Minimum = 200
Enter the Maximum = 400

The List of Pronic Numbers from 200 and 400
210   240   272   306   342   380