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


Please Help Members By Posting Answers For Below Questions

what type of questions arrive in interview over c programming?

1547


write a progrmm in c language take user interface generate table using for loop?

1571


What is action and transformation in spark?

587


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

760


An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

650






What is string function in c?

529


What is cohesion and coupling in c?

585


What is the use of getchar functions?

670


How do I determine whether a character is numeric, alphabetic, and so on?

616


What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

803


What is wrong in this statement?

597


What are the different file extensions involved when programming in C?

744


What is a null pointer in c?

587


What is the most efficient way to store flag values?

678


Difference between malloc() and calloc() function?

650