Python Program to Print Pronic Numbers from 1 to 100

Write a Python program to print Pronic numbers from 1 to 100 or within a range using a while loop. This Python example accepts the minimum and maximum values and displays the Pronic numbers within that range.

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

Python program to print Pronic numbers from 1 to n using the for loop. 

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   

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.