Table of Contents
“Armstrong Number Program” is the initial program from where most of the beginner developers will start to learn and write code in any language. An Armstrong number is a number that is the sum of its own digits each raised to the power of the number of digits is equal to the number itself.
Here is an example of check a armstrong number in PHP.
Armstrong Number Program :-
Below is the simple PHP program to check a number armstrong.
<?php
$number=153;
$sum=0;
$temp=$number;
while($temp!=0)
{
$reminder=$temp%10;
$sum=$sum+$reminder*$reminder*$reminder;
$temp=$temp/10;
}
if($number==$sum)
{
echo "It is an Armstrong number";
}
else
{
echo "It is not an armstrong number";
}
?>
Output :-
It is an Armstrong number