PHP Armstrong Number Program,How do I Find My Armstrong Number Using PHP, Check if a number is armstrong number or not Using PHP, Armstrong Number program in PHP with form
If user here takes value 153 (3 digits), then the number of digits is the number of their th power increases.
13 + 53 + 33 = 153
1 + 125 + 27 = 153, then this is the Armstrong number.
If user 1634 (4 digits) here takes the value,
14 + 64 + 34 +44 = 1634
1 + 1296 + 81 + 256 = 1634, then this is also the Armstrong number.
Example :-
armstrong-number.php
<html> <head> <title>Write a Program to Find Whether a Number is Armstrong or Not</title> </head> <body> <table> <form method="post"> <tr><td>Number</td><td><input type="text" name="number"></td></tr> <tr><td> </td><td><input type="Submit" value="numbers" name="numbers"></td></tr> </form> </table> </body> </html> <?php if(isset($_POST['numbers']) && $_POST['numbers']!='') { $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"; } } ?>