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
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | Palindrome Check
- PHP to check substring in a string
- PHP program to check for Anagram
- PHP | Check if all characters are lower case
- PHP | Program to check a string is a rotation of another string
- PHP | ctype_alnum() (Check for Alphanumeric)
- How to check an array is associative or sequential in PHP?
- How to check whether an array is empty using PHP?
- Why to check both isset() and !empty() function in PHP ?
- How to check form submission in PHP ?
- How to check if URL contain certain string using PHP?
- PHP | Check if a variable is a function
- PHP | Check if two arrays contain same elements
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.