We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d89189a commit b8d98f9Copy full SHA for b8d98f9
krishnamurthy.java
@@ -0,0 +1,29 @@
1
+import java.util.Scanner;
2
+class krishnamurthy
3
+{
4
+ int fact(int n)
5
+ {
6
+ int i,p=1;
7
+ for(i=n;i>=1;i--)
8
+ p=p*i;
9
+ return p;
10
+ }
11
+ public static void main(String args[])
12
13
+ Scanner sc=new Scanner(System.in);
14
+ int a,b,s=0;
15
+ System.out.print("Enter the number : ");
16
+ a=sc.nextInt();
17
+ int n=a;
18
+ while(a>0)
19
20
+ b=a%10;
21
+ s=s+fact(b);
22
+ a=a/10;
23
24
+ if(s==n)
25
+ System.out.print(n+" is a krishnamurthy number");
26
+ else
27
+ System.out.print(n+" is not a krishnamurthy number");
28
29
+}
0 commit comments