armstrong number algorithm code example
Example 1: armstrong number
sum of cubes of the digits
Example 2: armstrong number
temp=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(temp==sum)
printf("armstrong number ");
else
printf("not armstrong number");
return 0;
Example 3: armstrong number function
def is_armstrong_number(number: int)-> bool:
arm = str(number)
lenght = len(arm)
sum = 0
for digit in arm:
sum += int(digit)**lenght
return sum == number