What coding i use for armstrong | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

What coding i use for armstrong

plzz tell me

3rd Aug 2018, 1:35 AM
Rishab
Rishab - avatar
2 Answers
+ 9
Please show your attempts when asking for help, many thanks.
4th Aug 2018, 6:05 AM
Tashi N
Tashi N - avatar
0
/* you can copy and paste in your IDE then run you can also change variable 'number' to check if other numbers is Armstrong or no */ public class Armstrong { public static void main(String[] args) { int number = 1634, originalNumber, remainder, result = 0, n = 0; originalNumber = number; for (;originalNumber != 0; originalNumber /= 10, ++n); originalNumber = number; for (;originalNumber != 0; originalNumber /= 10) { remainder = originalNumber % 10; result += Math.pow(remainder, n); } if(result == number) System.out.println(number + " is an Armstrong number."); else System.out.println(number + " is not an Armstrong number."); } }
3rd Aug 2018, 2:49 AM
Mind To Machine 💻🕆
Mind To Machine 💻🕆 - avatar