Monday, August 6, 2018

phpMyPassion

Armstrong Number Program in PHP

PhpMyPassion
"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


About Author -

Hi, I am Anil.

Welcome to my eponymous blog! I am passionate about web programming. Here you will find a huge information on web development, web design, PHP, Python, Digital Marketing and Latest technology.

Subscribe to this Blog via Email :

Note: Only a member of this blog may post a comment.