PHP Program to Check Armstrong Number

Armstrong number or not in Php. This program is finding the number is Armstrong or not in PHP scripting. Program will check the number is armstrong number or not armstrong number in php

<?php 
$number=300;
$result=0;
$x=$number;
while($x!=0)
{
$bal=$x%10;
$result=$result+$bal*$bal*$bal;
$x=$x/10;
}
if($number==$result)
{
echo "it is an armstrong";
}
else
{
echo "it is not armstrong";
}
?>

 

Output:

it is not armstrong

Armstrong Number in PHP

An Armstrong three-digit number is an integer in which the sum of the cubes of its digits equals the number. The angstrom () is a length measurement unit for light wavelengths. It’s the same as 1010 metres, or 0.1 nanometers. Anders Jonas ngström, a 19th-century Swedish physicist, was the inspiration for the name.

If Else Statement in PHP

The if-else phrase is run regardless of whether the condition is true or false. The if-else statement differs from the if statement in a few ways. If the provided condition is true, one block of code is executed; if the condition is false, another block of code is executed.