# Program to Find nth Pronic Number

A Number is a Pronic number which is the product of two consecutive integers, that is, a number of the form num(num+1).

Example:

Given Number=90
product of two consecutive number 9*10=90
so, 90 is a Pronic Number.

Given Number=80
there are no consecutive multiple presents.
That's why 80 is not a  Pronic Number.

Problem statement:-  Program to Find nth Pronic Number.

Data requirement:-

Input Data:- rangenumber

Output Data:- rangenumber, letest

Program in C

Here is the source code of the C Program to Find nth Pronic Number.

Code:

//Nth Pronic Number
#include <stdio.h>
int
main ()
{
int i, rangenumber, num = 1, c = 0, letest = 0;
printf ("Enter the Nth value:");
scanf ("%d", &rangenumber);
while (c != rangenumber)
{
int flag=0;
for(i=0;i<=num;i++)
{
if(i*(i+1)==num)
{
flag=1;
break;
}
}

if(flag==1)
{
c++;
letest=num;
}
num = num + 1;
}
printf ("%dth Pronic number is %d", rangenumber, letest);
return 0;
}

Input/Output:
Enter the Nth value:10
10th Pronic number is 110

Program in C++

Here is the source code of the C++ Program to Find nth Pronic Number.

Code:

#include <iostream>
using namespace std;
int
main ()
{
int i, rangenumber, num = 1, c = 0, letest = 0;
cout<<"Enter the Nth value:";
cin>>rangenumber;
while (c != rangenumber)
{
int flag=0;
for(i=0;i<=num;i++)
{
if(i*(i+1)==num)
{
flag=1;
break;
}
}

if(flag==1)
{
c++;
letest=num;
}
num = num + 1;
}
cout<<rangenumber<<"th Pronic number is "<<letest;
return 0;
}

Input/Output:
Enter the Nth value:5
5th Pronic number is 30

Program in Java

Here is the source code of the Java Program to Find nth Pronic Number.

Code:

import java.util.Scanner;
public class NthPronicNumber {

public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
int  rangenumber, num = 1, c = 0, letest = 0,i;
System.out.println("Enter Nth number:");
rangenumber=cs.nextInt();

while (c != rangenumber)
{
int flag=0;
for(i=0;i<=num;i++)
{
if(i*(i+1)==num)
{
flag=1;
break;
}
}

if(flag==1)
{
c++;
letest=num;
}
num = num + 1;
}
System.out.println(rangenumber+"th Pronic number is "+letest);
cs.close();
}
}

Input/Output:
Enter Nth number:
17
17th Pronic number is 306

Program in Python

Here is the source code of the Program to Find nth Pronic Number.

Code:

import math
rangenumber=int(input("Enter a Nth Number:"))
c = 0
letest = 0
num = 1
while c != rangenumber:
flag = 0
for j in range(0, num + 1):
if j * (j + 1) == num:
flag = 1
break
if flag == 1:
c+=1
letest = num

num = num + 1
print(rangenumber,"th Pronic number is ",letest)

Input/Output:
Enter a Nth Number:45
45 th Pronic number is  2070

More:-