Java Program To Check If a Number Is Armstrong Number In Java | Java Practice Problems | Code Bode

preview_player
Показать описание
#Javaprogram check if a number is #Armstrongnumber in java | #javapracticeproblems

Armstrong - if the addition of cubes of digits of the number gives the original number

Algorithm-
// 1. Take input numbers from the user and assign value to variable temp. Initialize remainder and sum variable to 0
// 2. Iterate a while loop until number reduces to 0
// 3. take the remainder to take out the last digit in each loop
// 4. add the cube of the remainder in sum
// 5. divide the number by 10 to get rid of the last digit in a number
// 6. If sum and temporary variables are equal print Armstrong otherwise not Armstrong.

Рекомендации по теме
Комментарии
Автор

The best explanation out of all other videos for this program (up to 3 digits). Thanks!

jonsantos
Автор

It will be suitable only for 3 digits number..what about 1634, its an Armstrong number but this code shows it's not armstrong

arpitajuneja
visit shbcf.ru