Science, asked by ayesha59, 1 year ago

write a programe in java to aacept a number from user in a function int perfect (int n) void to check whether the number is perfect or not

Answers

Answered by Anonymous
1
// This program is to check whether the number is perfect is not.
class Perfect_number
{
public void accept (int n)
{
int i, num = 0;
for (i = 0; i<=n; i++)
{
if (n%i = = 0)

num = num + i;
}
}
if (num = = n)
{
System.out.println (" The given number is perfect number");
}
else
{
System.out.println ("The given number is not perfect");
}
}
}

Hope this helps you.


ayesha59: make Armstrong also
Anonymous: ok sure
ayesha59: using function fast
Similar questions