Find Armstrong Number

An Armstrong number is sum of the cubes of its digits is equal to the number itself.

There are six Armstrong numbers in the range of 0 and 999.

Armstrong number 1: 0
Armstrong number 2: 1
Armstrong number 3: 153
Armstrong number 4: 370
Armstrong number 5: 371
Armstrong number 6: 407

PHP Program Logic for Armstrong Number:

1. First You have to take the number.
2. Than taken number store it in a another variable.
3. Take a variable for sum.
4. Divide the number with 10 until quotient is 0.
5. Cube the remainder.
6. Compare sum variable and number variable.

PHP program to find Armstrong number

<?php
$num = 407;
$total = 0;
$temp = $num;
while($temp!=0)
{
	$rem = $temp%10;
	$total = $total+$rem*$rem*$rem;
	$temp = $temp/10;
}
if($num == $total)
{
	echo "Yes it is an Armstrong number";
}
else
{
	echo "No it is not an armstrong number";
}
?>

PHP program to find Armstrong number using HTML Form

<form method="post">
 <input type="text" name="number" placeholder="Enter number" />
 <input type="submit" value="Submit" />
</form>
<?php
if(isset($_POST['number']))
{
	$num = $_POST['number'];
	$total = 0;
	$temp = $num;
	while($temp!=0)
	{
		$rem = $temp%10;
		$total = $total+$rem*$rem*$rem;
		$temp = $temp/10;
	}
	if($num == $total)
	{
		echo "Yes it is an Armstrong number";
	}
	else
	{
		echo "No it is not an armstrong number";
	}
}
?>

Program Keywords: armstrong numbers list, armstrong numbers between 1 to 999, armstrong number program, armstrong numbers between 1 to 500, armstrong number php, armstrong number in c++, armstrong number program in php, armstrong number algorithm, find armstrong number, print armstrong number

Leave a Reply

Related Posts: You may like

Write a program find Factorial of a number

Write a PHP program to Print table of Number

Write a PHP program to print prime number

Write a PHP program to print number is Even or Odd

Tools:

Crypto Currency

PHPKIDA provides free online the best real-time crypto market price, news, predictions, index with graphs & historical data for 2000+ coins including bitcoin, ethereum, & altcoins from major cryptocurrency exchanges.

Visite Tool

Icon Generator

PHPKIDA provides free online icon generator. Our icon generator help you to edit, modify, resize and customize icon for your website and applications. Convert to a shap you like add icon border, you can change icon border color, border size, background color, icon shadow, icons color, icon size in your own way and save it as a png image.

Visite Tool

Youtube Video Downloader

PHPKIDA provides Free online YouTube video downloader to download YouTube videos quickly in MP4, 3GP, and more. Search your video and free fast download youtube videos.

Visite Tool

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.