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
Write a program on swapping (100, 50)
Explain how do you generate random numbers in c?
Which header file is used for clrscr?
Explain the use of function toupper() with and example code?
using only #include
How many levels of pointers have?
What is the use of #define preprocessor in c?
Explain About fork()?
Can two or more operators such as and be combined in a single line of program code?
What is static and auto variables in c?
write a program for the normal snake games find in most of the mobiles.
What is conio h in c?
What is variable initialization and why is it important?
What is the ANSI C Standard?
Why do we use & in c?