XMPP JavaScript Library

Program to find all Armstrong numbers (PHP)

An Armstrong number is an n digit number, which is equal to the sum of the nth powers of its digits. All the 1 digit numbers (1-9) are Armstrong number because 1*1=1 which is equals to number (1) itself, 2*1=2 which is equals to number(2) itself so on for all the 1 digit numbers (1-9).There are no 2 digit Armstrong numbers. Feel free to ask me if you still have doubt.

1 <?
2 armstrong(9999);
3 function armstrong($maximum_number)
4 {
5 $sum=0;
6 print("Armstrong numbers between 0 to $maximum_number are: ");
7
8 for($i=0; $i<=$maximum_number; $i++)
9 {
10 $num=$i;
11 $sum=0;
12 $len=strlen($i); //Length of number i.e number of digits in a number
13 while($num>0)
14 {
15 $rem=$num%10;
16 $power=pow($rem,$len);//Raise to the power of length of each digit in a number.
17 $sum=$sum+$power; //Sum of power of all digits of a number
18 $num=$num/10; // Calculate next number
19 }
20 if($sum==$i)
21 {
22 echo $i . "= Yes <br/>";
23 }
24 }
25 }
26 ?>
Add Your Comment
   
    Yes! I want to receive all comments by email

  by online_viagra on 07-Feb-2019 02:50 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by generic_cialis on 07-Feb-2019 12:53 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by cheap_cialis on 30-Jan-2019 06:56 pm
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by buy_viagra on 29-Jan-2019 07:28 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by viagra on 29-Jan-2019 01:08 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by fast on 28-Jan-2019 08:24 pm
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by cialis_online on 19-Jan-2019 07:57 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by buy_cialis on 11-Jan-2019 02:26 pm
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by buy_cialis on 10-Jan-2019 01:49 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by cialis_cheap on 09-Jan-2019 12:07 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by viagra on 06-Jan-2019 08:17 pm
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by generic on 03-Jan-2019 09:22 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by cheap_viagra on 03-Jan-2019 01:52 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by viagra on 21-Dec-2018 06:40 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by cialis on 29-Nov-2018 08:58 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by cialis on 28-Nov-2018 07:40 pm
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by buy_viagra on 28-Nov-2018 04:10 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by buy_viagra on 07-Nov-2018 09:02 am
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by chenlixiang on 07-Nov-2018 07:20 am

yves saint laurent

wedding dress [url=http://www.iphonexcase.us.com][b]iphone x case[/b][/url] http://www.timberlandsaleuk.co.uk
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by buy_cialis on 26-Oct-2018 04:51 pm
  • Reply
  •  0 Like
  •  0 Dislike
  • Report
  by hitesh on 19-Aug-2016 06:32 pm
Nice
  • Reply
  •  1 Like
  •  2 Dislike
  • Report
  by Deepak on 19-Mar-2015 11:33 pm
Wrong program not working
  • Reply
  •  2 Like
  •  3 Dislike
  • Report
  by jithesh on 09-Dec-2014 12:53 pm
im not getting the output \'_\'!
  • Reply
  •  2 Like
  •  4 Dislike
  • Report
  by Happy on 12-Nov-2014 04:43 pm
Very nice
  • Reply
  •  29 Like
  •  4 Dislike
  • Report
  by Miguel on 19-Sep-2014 01:22 am
Thank you for your code, it really helped me.
  • Reply
  •  9 Like
  •  2 Dislike
  • Report
  by gjghj on 09-Aug-2014 02:18 pm
xcfgxd
  • Reply
  •  2 Like
  •  2 Dislike
  • Report

Warning: include(ads/adbrite_300_250.php): failed to open stream: No such file or directory in /home2/sachinpu/public_html/pages/algorithm.php on line 33

Warning: include(ads/adbrite_300_250.php): failed to open stream: No such file or directory in /home2/sachinpu/public_html/pages/algorithm.php on line 33

Warning: include(): Failed opening 'ads/adbrite_300_250.php' for inclusion (include_path='.:/opt/cpanel/ea-php56/root/usr/share/pear') in /home2/sachinpu/public_html/pages/algorithm.php on line 33

About the author

Sachin Puri Hi, I am Sachin Puri, I am a Programmer. Programming is my work and it is the thing i like to do most in my free time.
You can catch Sachin Puri at