Home >>Python Programs >Python program to print all pronic numbers between 1 and 100

# Python program to print all pronic numbers between 1 and 100

### Python program to print all pronic numbers between 1 and 100

In this example, we will see a Python program through which we can print all the pronic numbers between 1 to 100.

Any given number is called as a pronic number if the value of that number is equal to the product of two consecutive integers of the form: n(n+1).

`Like 2(2+1) = 6 can be called as a pronic number.`

### ALGORITHM:

• STEP 1:isPronicNumber() determines whether a given number is the Pronic number or not.
1. Define a boolean variable flag and set its value to false.
2. Use for loop to iterate from 1 to given number and check whether i * (i + 1) is equal to the given number, for any value of i.
3. If a match is found, then set the flag to true, break the loop and returns the value of the flag.
• STEP 2:To display all Pronic numbers between 1 and 100,
1. Start a loop from 1 to 100, and make a call to isPronicNumber() method for each value from 1 to 100.
2. If isPronicNumber() returns true which signifies that number is Pronic, then display that number.
Program:
``````
#isPronicNumber() will determine whether a given number is a pronic number or not
def isPronicNumber(num):
flag = False;
for j in range(1, num+1):
#Checks for pronic number by multiplying consecutive numbers
if((j*(j+1)) == num):
flag = True;
break;
return flag;
#Displays pronic numbers between 1 and 100
print("Pronic numbers between 1 and 100: ");
for i in range(1, 101):
if(isPronicNumber(i)):
print(i),
print(" "),
```
```
Output:
Pronic numbers between 1 and 100:
2
6
12
20
30
42
56
72
90