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 | 15 No |
Post New Answer View All Answers
what type of questions arrive in interview over c programming?
write a progrmm in c language take user interface generate table using for loop?
What is action and transformation in spark?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
What is string function in c?
What is cohesion and coupling in c?
What is the use of getchar functions?
How do I determine whether a character is numeric, alphabetic, and so on?
What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?
What is wrong in this statement?
What are the different file extensions involved when programming in C?
What is a null pointer in c?
What is the most efficient way to store flag values?
Difference between malloc() and calloc() function?