00:01
Hello, so we need to write an algorithm to check if a number is an armstrong number.
00:06
An armstrong number is a number whose digits when cubed equal the same number.
00:16
So 153 is an example of that.
00:19
So to check this is really easy, we just need to take the digits of the number one by one and cube them to see if the number feels the condition or not.
00:33
So i'm going to start by defining a function that i'm going to call armstrong, that will take a number as parameter.
00:45
Now to get the digits of the number, we can use a simple trick using the module operator.
00:52
You notice that if i use 153 for example, modulo 10, the result will be 3.
01:02
And if i do 153 divided in 10, the result will be 3.
01:07
Will be 15.
01:08
So that way i can get the last digit of the number here and the rest here.
01:14
And we can use this for a algorithm...