Pronic number
Pronic number is the continuous two product number is equal to the given number.
Example-1:
Input : n = 6 Output : Pronic number Explain : 2 * 3 = 6. 2,3 are continuous number. So its "Pronic number".
Example-2:
Input : n = 30 Output : Pronic number Explain : 5 * 6 = 30. 5,6 are continuous number. So its "Pronic number".
Example-3:
Input : n = 5 Output : Not a Pronic number Explain : There is no two continuous of product number is equal to 5.
Solution
public class Main { public static void main(String [] args) { int n = 6; for(int i = 0; i <= n;i++) { if(i*(i+1) == n) { System.out.print("Pronic number"); break; } if(i*(i+1) > n) { System.out.print("Not a pronic number"); break; } } } }
n = 6 for x in range(0,n+1): if(x * (x+1) == n): print("Pronic number") break if(x * (x+1) > n): print("Not a pronic number") break
Output
Pronic number