Given a number, we need to check whether it is an armstrong number or not in PHP. An Armstrong number is the one whose value is equal to the sum of the cubes of its digits.
Input : 407 Output : Yes 407 = (4*4*4) + (0*0*0) + (7*7*7) = 64 + 0 + 343 = 407 Input : 303 Output : No
Approach: For every digit r in input number x, compute r3. If sum of all such values is equal to n, then print “Yes”, else “No”.
Time Complexity: O(num), where num is the number of digits in the given number.
- PHP | Check if a number is Perfect number
- PHP | check if a number is Even or Odd
- PHP | Check if a number is prime
- Check whether a given Number is Power-Isolated or not
- PHP | Sum of digits of a number
- PHP | Factorial of a number
- How to convert a string into number in PHP?
- PHP | Number of week days between two dates
- PHP | Find the number of sub-string occurrences
- HTML | DOM Input Number Object
- Program to find the number of days between two dates in PHP
- PHP program to Generate the random number in the given range (min, max)
- PHP | Palindrome Check
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.