GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Java/Others/Krishnamurthy.java at master · whyhe/Java Expand file tree/ Copy pathKrishnamurthy.javaMore file actions 30 lines (27 loc) · 711 Bytes / Copy pathKrishnamurthy.javaFile metadata and controls30 lines (27 loc) · 711 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 package Others; import java.util.Scanner; class Krishnamurthy { static 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"); sc.close(); } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |