Pronic Number
A pronic number, also known as an oblong number, is a positive integer that is the product of two consecutive integers, i.e., n(n+1) for some integer n. In other words, a pronic number is the product of any two consecutive numbers.
For example, 6 is a pronic number because it can be expressed as the product of 2 and 3, which are consecutive integers. Similarly, 12 is a pronic number because it can be expressed as the product of 3 and 4. The first few pronic numbers are: 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, and so on.
The name "pronic" comes from the Greek word "πρόνοια" (prónia), which means foresight or planning, because pronic numbers can be used in certain mathematical situations where planning or foresight is required.
72 Is an Pronic Number
89 Is not an Pronic Number
35 Is not an Pronic Number
30 Is an Pronic Number
72 is a pronic number because it can be expressed as the product of two consecutive integers, namely 8 and 9, that is, 8 x 9 = 72.
89 is not a pronic number because it cannot be expressed as the product of two consecutive integers. The two consecutive integers closest to 89 are 9 and 10, but their product, 9 x 10 = 90, is not equal to 89. Therefore, 89 is not a pronic number.
35 is not a pronic number because it cannot be expressed as the product of two consecutive integers. The two consecutive integers closest to 35 are 5 and 6, but their product, 5 x 6 = 30, is not equal to 35. Therefore, 35 is not a pronic number.
30 is a pronic number because it can be expressed as the product of two consecutive integers, namely 5 and 6, that is, 5 x 6 = 30. Therefore, 30 is a pronic number.
/*
C Program
+ Check if a given number is Pronic Number or not
*/
#include<stdio.h>
#include<math.h>
void is_pronic_no(int number)
{
//Getting square root of a number
int square = (int) sqrt(number);
//Use to indicate number is pronic or not
//Initial set zero means number is not pronic
int flag = 0;
for (int i = square; i >= 0 && flag == 0 ; --i)
{
//Check that whether product of two consecutive integers is equal to given number?
if(i*(i+1)==number)
{
//When Yes
flag = 1;
}
}
if(flag==1)
{
//When Yes
printf("%d Is an Pronic Number\n",number);
}
else
{
//When No
printf("%d Is not an Pronic Number\n",number);
}
}
int main(){
//Test Case
// 72 = 7*8
is_pronic_no(72);
is_pronic_no(89);
is_pronic_no(35);
//30 = 5 * 6
is_pronic_no(30);
return 0;
}
Output
72 Is an Pronic Number
89 Is not an Pronic Number
35 Is not an Pronic Number
30 Is an Pronic Number
/*
C++ Program
Check if a given number is Pronic Number or not
*/
#include<iostream>
#include<math.h>
using namespace std;
class MyNumber {
public:
void is_pronic_no(int number) {
//Getting square root of a number
int square = (int) sqrt(number);
//Use to indicate number is pronic or not
//Initial set false means number is not pronic
bool flag = false;
for (int i = square; i >= 0 && flag == false; --i) {
//Check that whether product of two consecutive integers is equal to given number?
if (i *(i + 1) == number) {
//When Yes
flag = true;
}
}
if (flag == true) {
//When Yes
cout << number << " Is an Pronic Number\n";
} else {
//When No
cout << number << " Is not an Pronic Number\n";
}
}
};
int main() {
MyNumber obj;
//Test Case
// 72 = 7*8
obj.is_pronic_no(72);
obj.is_pronic_no(89);
obj.is_pronic_no(35);
//30 = 5 *6
obj.is_pronic_no(30);
return 0;
}
Output
72 Is an Pronic Number
89 Is not an Pronic Number
35 Is not an Pronic Number
30 Is an Pronic Number
/*
Java Program
Check if a given number is Pronic Number or not
*/
public class MyNumber {
public void is_pronic_no(int number)
{
//Getting square root of a number
int square = (int) Math.sqrt(number);
//Use to indicate number is pronic or not
//Initial set false means number is not pronic
boolean flag = false;
for (int i = square; i >= 0 && flag == false ; --i)
{
//Check that whether product of two consecutive integers is equal to given number?
if(i*(i+1)==number)
{
//When Yes
flag = true;
}
}
if(flag==true)
{
//When Yes
System.out.print(number+" Is an Pronic Number\n");
}
else
{
//When No
System.out.print(number+" Is not an Pronic Number\n");
}
}
public static void main(String[] args) {
MyNumber obj = new MyNumber();
//Test Case
// 72 = 7*8
obj.is_pronic_no(72);
obj.is_pronic_no(89);
obj.is_pronic_no(35);
//30 = 5 * 6
obj.is_pronic_no(30);
}
}
Output
72 Is an Pronic Number
89 Is not an Pronic Number
35 Is not an Pronic Number
30 Is an Pronic Number
/*
C# Program
Check if a given number is Pronic Number or not
*/
using System;
public class MyNumber {
public void is_pronic_no(int number) {
//Getting square root of a number
int square = (int) Math.Sqrt(number);
//Use to indicate number is pronic or not
//Initial set false means number is not pronic
Boolean flag = false;
for (int i = square; i >= 0 && flag == false; --i) {
//Check that whether product of two consecutive integers is equal to given number?
if (i * (i + 1) == number) {
//When Yes
flag = true;
}
}
if (flag == true) {
//When Yes
Console.Write(number + " Is an Pronic Number\n");
} else {
//When No
Console.Write(number + " Is not an Pronic Number\n");
}
}
public static void Main(String[] args) {
MyNumber obj = new MyNumber();
//Test Case
// 72 = 7*8
obj.is_pronic_no(72);
obj.is_pronic_no(89);
obj.is_pronic_no(35);
//30 = 5 * 6
obj.is_pronic_no(30);
}
}
Output
72 Is an Pronic Number
89 Is not an Pronic Number
35 Is not an Pronic Number
30 Is an Pronic Number
# Python 3 Program
# Check if a given number is Pronic Number or not
class MyNumber :
def is_pronic_no(self, number) :
# Getting square root of a number
square = int(number**(0.5))
# Use to indicate number is pronic or not
# Initial set false means number is not pronic
flag = False
i = square
while (i >= 0 and flag == False) :
# Check that whether product of two consecutive integers is equal to given number?
if (i * (i + 1) == number) :
# When Yes
flag = True
i -= 1
if (flag == True) :
# When Yes
print(number ," Is an Pronic Number")
else :
# When No
print(number ," Is not an Pronic Number")
def main() :
obj = MyNumber()
# Test Case
# 72 = 7*8
obj.is_pronic_no(72)
obj.is_pronic_no(89)
obj.is_pronic_no(35)
# 30 = 5 * 6
obj.is_pronic_no(30)
if __name__ == "__main__":
main()
Output
72 Is an Pronic Number
89 Is not an Pronic Number
35 Is not an Pronic Number
30 Is an Pronic Number
# Ruby Program
# Check if a given number is Pronic Number or not
class MyNumber
def is_pronic_no(number)
# Getting square root of a number
square = (number**(0.5)).to_i
# Use to indicate number is pronic or not
# Initial set false means number is not pronic
flag = false
i = square
while (i >= 0 and flag == false)
# Check that whether product of two consecutive integers is equal to given number?
if (i * (i + 1) == number)
# When Yes
flag = true
end
i -= 1
end
if (flag == true)
# When Yes
print(number ," Is an Pronic Number\n")
else
# When No
print(number ," Is not an Pronic Number\n")
end
end
end
def main()
obj = MyNumber.new()
# Test Case
# 72 = 7*8
obj.is_pronic_no(72)
obj.is_pronic_no(89)
obj.is_pronic_no(35)
# 30 = 5 * 6
obj.is_pronic_no(30)
end
main()
Output
72 Is an Pronic Number
89 Is not an Pronic Number
35 Is not an Pronic Number
30 Is an Pronic Number
/*
Scala Program
Check if a given number is Pronic Number or not
*/
class MyNumber {
def is_pronic_no(number: Int): Unit = {
//Getting square root of a number
var square: Int = (scala.math.sqrt(number)).toInt;
//Use to indicate number is pronic or not
//Initial set false means number is not pronic
var flag: Boolean = false;
var i: Int = square;
while (i >= 0 && flag == false) {
//Check that whether product of two consecutive integers is equal to given number?
if (i * (i + 1) == number) {
//When Yes
flag = true;
}
i -= 1;
}
if (flag == true) {
//When Yes
print(s"$number Is an Pronic Number\n");
} else {
//When No
print(s"$number Is not an Pronic Number\n");
}
}
}
object Main {
def main(args: Array[String]): Unit = {
var obj: MyNumber = new MyNumber();
//Test Case
// 72 = 7*8
obj.is_pronic_no(72);
obj.is_pronic_no(89);
obj.is_pronic_no(35);
//30 = 5 * 6
obj.is_pronic_no(30);
}
}
Output
72 Is an Pronic Number
89 Is not an Pronic Number
35 Is not an Pronic Number
30 Is an Pronic Number
/*
Swift 4 Program
Check if a given number is Pronic Number or not
*/
import Foundation
class MyNumber {
func is_pronic_no(_ number: Int) {
//Getting square root of a number
let square: Int = Int(Double(number).squareRoot());
//Use to indicate number is pronic or not
//Initial set false means number is not pronic
var flag: Bool = false;
var i: Int = square;
while (i >= 0 && flag == false) {
//Check that whether product of two consecutive integers is equal to given number?
if (i * (i + 1) == number) {
//When Yes
flag = true;
}
i -= 1;
}
if (flag == true) {
//When Yes
print(number ," Is an Pronic Number");
} else {
//When No
print(number ," Is not an Pronic Number");
}
}
}
func main() {
let obj: MyNumber = MyNumber();
//Test Case
// 72 = 7*8
obj.is_pronic_no(72);
obj.is_pronic_no(89);
obj.is_pronic_no(35);
//30 = 5 * 6
obj.is_pronic_no(30);
}
main();
Output
72 Is an Pronic Number
89 Is not an Pronic Number
35 Is not an Pronic Number
30 Is an Pronic Number
<?php
/*
Php Program
Check if a given number is Pronic Number or not
*/
class MyNumber {
public function is_pronic_no($number) {
//Getting square root of a number
$square = intval(sqrt($number));
//Use to indicate number is pronic or not
//Initial set false means number is not pronic
$flag = false;
for ($i = $square; $i >= 0 && $flag == false; --$i) {
//Check that whether product of two consecutive integers is equal to given number?
if ($i *($i + 1) == $number) {
//When Yes
$flag = true;
}
}
if ($flag == true) {
//When Yes
echo($number ." Is an Pronic Number\n");
} else {
//When No
echo($number ." Is not an Pronic Number\n");
}
}
};
function main() {
$obj = new MyNumber();
//Test Case
// 72 = 7*8
$obj->is_pronic_no(72);
$obj->is_pronic_no(89);
$obj->is_pronic_no(35);
//30 = 5 *6
$obj->is_pronic_no(30);
}
main();
Output
72 Is an Pronic Number
89 Is not an Pronic Number
35 Is not an Pronic Number
30 Is an Pronic Number
/*
Node Js Program
Check if a given number is Pronic Number or not
*/
class MyNumber {
is_pronic_no(number) {
//Getting square root of a number
var square = parseInt(Math.sqrt(number));
//Use to indicate number is pronic or not
//Initial set false means number is not pronic
var flag = false;
for (var i = square; i >= 0 && flag == false; --i) {
//Check that whether product of two consecutive integers is equal to given number?
if (i *(i + 1) == number) {
//When Yes
flag = true;
}
}
if (flag == true) {
//When Yes
process.stdout.write(number + " Is an Pronic Number\n");
} else {
//When No
process.stdout.write(number + " Is not an Pronic Number\n");
}
}
}
function main(args) {
var obj = new MyNumber();
//Test Case
// 72 = 7*8
obj.is_pronic_no(72);
obj.is_pronic_no(89);
obj.is_pronic_no(35);
//30 = 5 *6
obj.is_pronic_no(30);
}
main();
Output
72 Is an Pronic Number
89 Is not an Pronic Number
35 Is not an Pronic Number
30 Is an Pronic Number
Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.
New Comment