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 33d233c commit 482f63bCopy full SHA for 482f63b
Conditional Statement/ArmStrong.java
@@ -0,0 +1,24 @@
1
+import java.util.Scanner;
2
+public class ArmStrong {
3
+ static int xpown (int x, int n) {
4
+ if (n==0) {
5
+ return 1;
6
+ }
7
+ return x * xpown(x, n-1);
8
9
+
10
+ public static void main(String[] args) {
11
+ // Write your code here
12
+ Scanner sc = new Scanner(System.in);
13
+ String str = sc.next();
14
+ int num = Integer.parseInt(str);
15
+ int res=0;
16
17
+ for (int i=0; i<str.length(); i++) {
18
+ int current = Character.getNumericValue(str.charAt(i));
19
+ res = xpown(current, str.length()) + res;
20
21
22
+ System.out.print((res == num)? true : false);
23
24
+}
0 commit comments