Write a program in java to check the number is ram ji number or not. for example- 145 = !1+!4+!5=1+24+120=145
Answers
Answered by
6
ort java.util.*;
public class SpecialNumber
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number to be checked.");
int n=sc.nextInt();
int s=0;int t=n;
while(t!=0)
{
int a=t%10;int f=1;
for(int i=1;i<=a;i++)
{
f=f*i;
}
s=s+f;
t=t/10;
}
if(s==n)
{
System.out.println(n+" is a Special Number.");
}
else
{
System.out.println(n+" is not a Special Number.");
}
}}
public class SpecialNumber
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number to be checked.");
int n=sc.nextInt();
int s=0;int t=n;
while(t!=0)
{
int a=t%10;int f=1;
for(int i=1;i<=a;i++)
{
f=f*i;
}
s=s+f;
t=t/10;
}
if(s==n)
{
System.out.println(n+" is a Special Number.");
}
else
{
System.out.println(n+" is not a Special Number.");
}
}}
Similar questions
English,
7 months ago
Computer Science,
7 months ago
Computer Science,
7 months ago
Biology,
1 year ago
Biology,
1 year ago