Skip to content

Commit

Permalink
➕ Armstring
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunlong committed Jun 17, 2021
1 parent 7185aad commit 887fa0b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
20 changes: 20 additions & 0 deletions Maths/Armstrong/Armstrong.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
public class AverageList {
public static void main(String[] args) {
System.out.println(isArmStrong(370));
}

private static boolean isArmStrong(int n) {
int temp = n;
int rem = 0;
int sum = 0;
System.out.println(temp);

while (n != 0) {
rem = n % 10;
sum += rem * rem * rem;
n = n / 10;
}

return sum == temp;
}
}
38 changes: 38 additions & 0 deletions Maths/Armstrong/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Armstrong

**What is Armstrong?**

An armstrong number is a number which equal to the sum of the cubes of its individual digits.

**Explanation**

`370` is an Armstrong number because `3*3*3 + 7*7*7 + 0*0*0 = 370`.

**Example**

Write a function to checks whether a given number is an armstrong number or not.

**Java**

```js
public class AverageList {
public static void main(String[] args) {
System.out.println(isArmStrong(370));
}

private static boolean isArmStrong(int n) {
int temp = n;
int rem = 0;
int sum = 0;
System.out.println(temp);

while (n != 0) {
rem = n % 10;
sum += rem * rem * rem;
n = n / 10;
}

return sum == temp;
}
}
```
1 change: 0 additions & 1 deletion Strings/AllCharactersSame/AllCharactersSame.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
public class AllCharactersSame {

public static void main(String[] args) {
System.out.println(isAllCharactersSame(""));
System.out.println(!isAllCharactersSame("aab"));
Expand Down

0 comments on commit 887fa0b

Please sign in to comment.