Skip to content

Commit

Permalink
Added code for pronic number. Closes #83
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohxn16 committed Oct 15, 2023
1 parent 7c1ef37 commit 02eb04e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions PronicNumber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.Scanner;
public class PronicNumber{
public static boolean isPronic(int n){
for(int i = 0; i < Math.sqrt(n); i++){
if(n == i * (i+1)) return true;
}
return false;
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n;
System.out.println("Enter a number : ");
n = sc.nextInt();
if(isPronic(n)){
System.out.println(n + " is a pronic number.");
}
else{
System.out.println(n + " is not a pronic number");
}
sc.close();
}
}

0 comments on commit 02eb04e

Please sign in to comment.