Synced the directory structure to that of Python repo

This commit is contained in:
Varun Upadhyay
2017-10-13 06:57:26 -07:00
parent 7dd8fd16cc
commit e53249ba23
25 changed files with 0 additions and 0 deletions

29
Others/krishnamurthy.java Normal file
View File

@ -0,0 +1,29 @@
import java.util.Scanner;
class krishnamurthy
{
int fact(int n)
{
int i,p=1;
for(i=n;i>=1;i--)
p=p*i;
return p;
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,b,s=0;
System.out.print("Enter the number : ");
a=sc.nextInt();
int n=a;
while(a>0)
{
b=a%10;
s=s+fact(b);
a=a/10;
}
if(s==n)
System.out.print(n+" is a krishnamurthy number");
else
System.out.print(n+" is not a krishnamurthy number");
}
}