Hey guys, welcome again to the tutorial on python programming. Today we shall be discussing about printing strong numbers. Now in in terms of maths we call it the numbers which actually whose sum of factorial of digits is equal to the original number that is known as strong number, okay. So what we are going to do is for example 145 factorial of one four plus factorial of four plus factorial of five gives it 145. Hence, 145 is a strong number, okay, so what we are going to do is as per the logic we are going to extract the numbers and find the factorial of each extracted number as a digit right from the right hand side and keep on storing the sum of that particular digit into the factorial of the digit into a variable right. And then finally be able to check if that variable is equal to the original number Right, so let's start.
Once again I tell you strong numbers are the numbers who some of factorial of digits is equal to the original number, right? So I define a variable someone as zero initializing it at zero. Then of course, the other number is we input the number which has to be checked, whether it's a strong number or not. So we have initialized the very inputted or the insert number into temp variable, then we have taken a while loop while the number is positive or greater than zero. So I initialize a variable i by one f by one and then extract the digit from the number in R, and then we check by i is less than or equal to art in order to find the factorial of that digit, extracted digit. So f is the variable which is storing the factorial and then of course is equal to i plus one.
And then we proceed on to the next. But before that we tried to store the computed factorial of the digit, the extracted digit in the variable sum one, and then we define the new number as number divided by 10. So that we extract one digit from the right. And then once the loop is over, we check whether the sum one is equal to temp, that is the last earlier number, the original number. And if that is so we print the message Wow, the number is a strong number, right? Otherwise, the else statement is executed with say sorry, the number is not a strong number.
So my dear friends, this program can be asked in your exam. So please try to get to the definition of the word strong number, which says strong numbers and the numbers whose sum of factorial of digits is equal to the origin Number, for example 145. Right. So this is again, good program, important program which executes to that essence of learning.