# Pronic Number

Here given code implementation process.

``````/*
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 