26 lines
772 B
PHP
26 lines
772 B
PHP
|
// If the sum of cubes of individual digits of a number is equal to the number itslef then it is called Armstrong Number.
|
||
|
<?php
|
||
|
if(isset($_POST['number']) && $_POST['number']!='')
|
||
|
{
|
||
|
|
||
|
$number = $_POST[ 'number' ]; // get the number entered by user
|
||
|
|
||
|
$temp = $number;
|
||
|
$sum = 0;
|
||
|
|
||
|
while($temp != 0 )
|
||
|
{
|
||
|
$remainder = $temp % 10; //find reminder
|
||
|
$sum = $sum + ( $remainder * $remainder * $remainder );
|
||
|
$temp = $temp / 10;
|
||
|
|
||
|
}
|
||
|
if( $number == $sum )
|
||
|
{
|
||
|
echo "$number is an Armstrong Number";
|
||
|
}else
|
||
|
{
|
||
|
echo "$number is not an Armstrong Number";
|
||
|
}
|
||
|
}
|
||
|
?>
|