File tree Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Original file line number Diff line number Diff line change
1
+ public class AverageList {
2
+ public static void main (String [] args ) {
3
+ System .out .println (isArmStrong (370 ));
4
+ }
5
+
6
+ private static boolean isArmStrong (int n ) {
7
+ int temp = n ;
8
+ int rem = 0 ;
9
+ int sum = 0 ;
10
+ System .out .println (temp );
11
+
12
+ while (n != 0 ) {
13
+ rem = n % 10 ;
14
+ sum += rem * rem * rem ;
15
+ n = n / 10 ;
16
+ }
17
+
18
+ return sum == temp ;
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ # Armstrong
2
+
3
+ ** What is Armstrong?**
4
+
5
+ An armstrong number is a number which equal to the sum of the cubes of its individual digits.
6
+
7
+ ** Explanation**
8
+
9
+ ` 370 ` is an Armstrong number because ` 3*3*3 + 7*7*7 + 0*0*0 = 370 ` .
10
+
11
+ ** Example**
12
+
13
+ Write a function to checks whether a given number is an armstrong number or not.
14
+
15
+ ** Java**
16
+
17
+ ``` js
18
+ public class AverageList {
19
+ public static void main (String [] args ) {
20
+ System .out .println (isArmStrong (370 ));
21
+ }
22
+
23
+ private static boolean isArmStrong (int n ) {
24
+ int temp = n;
25
+ int rem = 0 ;
26
+ int sum = 0 ;
27
+ System .out .println (temp);
28
+
29
+ while (n != 0 ) {
30
+ rem = n % 10 ;
31
+ sum += rem * rem * rem;
32
+ n = n / 10 ;
33
+ }
34
+
35
+ return sum == temp;
36
+ }
37
+ }
38
+ ```
Original file line number Diff line number Diff line change 1
1
public class AllCharactersSame {
2
-
3
2
public static void main (String [] args ) {
4
3
System .out .println (isAllCharactersSame ("" ));
5
4
System .out .println (!isAllCharactersSame ("aab" ));
You can’t perform that action at this time.
0 commit comments