Armstrong number Program in PHP


Prev Tutorial Next Tutorial

Armstrong number Program in PHP

A 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..

Armstrong number Program in PHP

<?php

$num=153;
$sum=0;
$temp=$num;
while($temp!=0)
{
$rem=$temp%10;
$sum=$sum+$rem*$rem*$rem;
$temp=$temp/10;
}
if($num==$sum)
{
echo "Armstrong number";
}
else
{
echo "not an armstrong number";
}

?>

Output

	
Armstrong number

Prev Tutorial Next Tutorial

Advertisements
z
Download Projects

Advertisements

Download WhatsApp Status Video

Buy This Ad Space Only $50 per Month, Ad Size 300X250 Contact on: [email protected] WhatsApp no. 8882538826

Google Adsense Advertisements