## Pronic Numbers between a range

Back to Programming

### Description

Before seeing the program please follow the previous program check pronic number

A number is said to be a pronic number if the number is the product of two consecutive integer numbers.

For example, if we consider the number 72, it is the product of two consecutive integers 8 and 9. Therefore, 72 is a pronic number.

Now, if we consider a number 16, it is the product of 2 and 8 or 4 and 4 but no one is the consecutive integers. Therefore, 16 is not a pronic number.

For this program, first, the ranges are taken as input. For each number between the ranges, a loop is executed from 1 to half of the number and if the number is the product of any two consecutive numbers then the number is displayed as output.

### Algorithm

``````INPUT: The ranges
OUTPUT: Pronic numbers between the given ranges
PROCESS:
Step 1: [Taking the inputs]
Step 2: [Finding the pronic number]
For k=m to n repeat
For i=0 to k/2 repeat
If i×(i+1)=k then
Print k
[End of ‘if’]
[End of ‘for’ loop]
[End of ‘for’ loop]
Step 3: Stop.
``````

## Time Complexity:

for(j=m;j<=n;j++)----------------------------------------O(p)

{

if(j==0)------------------------------------------O(1)

printf("%d ",j);

//checking if the number is the product of

//two consecutive numbers

for(i=1;i<=j/2;i++)--------------------------O(j)

{

if(i*(i+1)==j)-----------------------O(1)

printf("%d ",j);

}

}

The time complexity of this program is O(p*j) where ‘p’ is the number between the ranges and ‘j’ is each number between the range that is to be checked for pronic number.

## Space Complexity:

The space complexity of this program is O(1) as it requires a constant number of space to execute for any given range.