Computer Science, asked by srijansrivastav, 1 year ago

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 sangrish03p58hbs
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.");
        }
    }}
Similar questions