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 is a lookup table in c?
to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?
Explain what is wrong with this statement? Myname = ?robin?;
Explain what will be the outcome of the following conditional statement if the value of variable s is 10?
What is || operator and how does it function in a program?
What kind of structure is a house?
What is scope rule in c?
What is the difference between functions getch() and getche()?
Why is extern used in c?
What are dangling pointers? How are dangling pointers different from memory leaks?
Explain modulus operator.
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
What header files do I need in order to define the standard library functions I use?
Can i use “int” data type to store the value 32768? Why?
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function