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 c mean in standard form?
What are actual arguments?
What are the preprocessor categories?
Explain what is wrong with this statement? Myname = ?robin?;
Explain what is the use of a semicolon (;) at the end of every program statement?
What is c mainly used for?
Write a program to swap two numbers without using third variable?
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
How are strings stored in c?
Define macros.
What does emoji p mean?
Explain spaghetti programming?
What is "Hungarian Notation"?
What is modifier & how many types of modifiers available in c?
if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0