Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Arm Strong Number
- * Date : 25.05.19
- */
- public class ArmStrong {
- public static void main(String args[]) {
- System.out.print("The Arm Strong numbers: ");
- for(int i = 1; i <= 1000; i++) {
- if(arm(i)) System.out.print(i + " ");
- }
- }
- static boolean arm(int a) {
- int result = 0, n = a;
- while(a != 0) {
- int k = a % 10;
- result += k * k * k;
- a /= 10;
- }
- if(result == n) return true;
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement