write a program to check whether a number is Peterson or not.
Answer Posted / deeksha shaw
import java.util.Scanner;
public class peterson
{
public static void main(String args[])
{
int n,f=1;
Scanner in=new Scanner(System.in);
System.out.println("enter a number");
n=in.nextInt();
for(int a=1;a<=n;a++)
f=f*a;
if (f==n)
System.out.println(" it is a Peterson number");
else
System.out.println("it is not a Peterson number");
}
}
| Is This Answer Correct ? | 11 Yes | 16 No |
Post New Answer View All Answers
What does the error 'Null Pointer Assignment' mean and what causes this error?
What is spark map function?
What is bin sh c?
What is wrong with this declaration?
Explain 'bit masking'?
Can you subtract pointers from each other? Why would you?
What is a #include preprocessor?
Is c procedural or object oriented?
Why is c called c not d or e?
What is volatile keyword in c?
Where can I get an ansi-compatible lint?
Why main is used in c?
we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?
Explain what is the most efficient way to store flag values?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10