Advertisement
fahimkamal63

Arm Strong Number

May 25th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. /*
  2.  * Arm Strong Number
  3.  * Date : 25.05.19
  4.  */
  5. public class ArmStrong {
  6.     public static void main(String args[]) {       
  7.         System.out.print("The Arm Strong numbers: ");      
  8.         for(int i = 1; i <= 1000; i++) {
  9.             if(arm(i)) System.out.print(i + " ");
  10.         }
  11.     }
  12.     static boolean arm(int a) {
  13.         int result = 0, n = a;
  14.         while(a != 0) {
  15.             int k = a % 10;
  16.             result += k * k * k;
  17.             a /= 10;
  18.         }
  19.         if(result == n) return true;
  20.         return false;
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement