what is armstrong numbers code example
Example 1: armstrong number
sum of cubes of the digits
Example 2: armstrong number
temp=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(temp==sum)
printf("armstrong number ");
else
printf("not armstrong number");
return 0;
Example 3: Armstrong number
<form method="post">
Enter the Number:
<input type="number" name="number">
<input type="submit" value="Submit">
</form>
<?php
if ($_POST) {
$number = $_POST['number'];
$a = $number;
$sum = 0;
while ($a != 0) {
$rem = $a % 10;
$sum = $sum + ($rem * $rem * $rem) || $sum = $rem;
$a = $a / 10;
}
if ($number == $sum) {
echo "Yes $number an Armstrong Number";
} else {
echo "$number is not an Armstrong Number";
}
}
$num=300;
$total=0;
$x=$num;
while($x!=0){
$rem=$x%10;
$total=$total+($rem*$rem*$rem);
$x=$x/10;
}
if($num==$total){
echo "Yes it is an Armstrong number";}
else
{echo "No it is not an armstrong number";}