Computer Science, asked by ojeshkumarsaini, 7 months ago

Write a program in Java check the given number is perfect number or prime number using switch case​

Answers

Answered by dharshan212007
2

Explanation:

import java.util.Scanner;

public class Perfect

{

public static void main(String[] args)

{

int n, sum = 0;

Scanner s = new Scanner(System.in);

System.out.print("Enter any integer you want to check:");

n = s.nextInt();

for(int i = 1; i < n; i++)

{

if(n % i == 0)

{

sum = sum + i;

}

}

if(sum == n)

{

System.out.println("Given number is Perfect");

}

else

{

System.out.println("Given number is not Perfect");

}

}

int divisor(int x)

{

return x;

}

}

Answered by anitajha1243
1

Answer:

join our guild 71108736

Explanation:

join our guild 71108736

join our guild 71108736

Similar questions