Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class pronic{
- static int s,p,q,r;
- pronic(){
- p = 1;
- }
- public static void main(){
- acceptnum();
- pronic ob = new pronic();
- ob.check();
- }
- static void acceptnum(){
- System.out.println("enter a number");
- Scanner sc = new Scanner(System.in);
- s = sc.nextInt();
- }
- boolean ispronic(int v){
- if(v >s){
- return false;
- }
- if(s%v ==0 && s%(v+1) ==0 && v*(v+1) == s){
- return true;
- }
- else{
- p = p+1;
- boolean k = ispronic(p);
- if(k == true){
- return true;
- }
- else return false;
- }
- }
- void check(){
- boolean f = ispronic(p);
- if(f == true){
- System.out.println("pronic");
- } else {
- System.out.println("not pronic");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment