PHP | Check if a number is armstrong number Last Updated : 30 Apr, 2021 Comments Improve Suggest changes Like Article Like Report 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.Examples: 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". Php <?php // PHP code to check whether a number is // armstrong number or not // function to check whether the number is // armstrong number or not function armstrongCheck($number){ $sum = 0; $x = $number; while($x != 0) { $rem = $x % 10; $sum = $sum + $rem*$rem*$rem; $x = $x / 10; } // if true then armstrong number if ($number == $sum) return 1; // not an armstrong number return 0; } // Driver Code $number = 407; $flag = armstrongCheck($number); if ($flag == 1) echo "Yes"; else echo "No" ?> Output: Yes Time Complexity: O(num), where num is the number of digits in the given number. Comment More infoAdvertise with us Next Article PHP | Check if a number is armstrong number A ayushjauhari14 Follow Improve Article Tags : Web Technologies PHP DSA Similar Reads PHP | Check if a number is Perfect number A perfect number is a number if it is equal to the sum of its factors,that is original number is equal to sum of all its factors excluding the number itself. We have already discuss how to check if a number is perfect or not in this article. In this article we will discuss about how to do the same i 2 min read Check if a Linked List is an Armstrong Number Given a singly linked list List containing N nodes representing a number, the task is to check whether the given linked list is an Armstrong number. Print "1" if the given linked list is an Armstrong number, else print "0". Note: An Armstrong number is a number that is equal to the sum of its own di 15 min read PHP | Check if a number is prime A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The smallest prime number is 2, which is the only even prime number. All other even numbers are not prime because they are divisible by 2.2 is prime because it can only be divided by 1 and 2.3 is 3 min read PHP check if a number is Even or Odd Checking if a number is even or odd involves determining whether the number is divisible by 2. An even number has no remainder when divided by 2, while an odd number has a remainder of 1. This can be done using various methods like modulo or bit manipulation.Examples :Input : 42 Output : Even Explan 3 min read Armstrong Numbers between two integers A positive integer with digits a, b, c, d... is called an Armstrong number of order n if following condition is satisfied. abcd... = an + bn + cn + dn +... 153 = 1*1*1 + 5*5*5 + 3*3*3 = 1 + 125 + 27 = 153 Therefore, 153 is an Armstrong number. Examples: Input : 100 400 Output :153 370 371 Explanatio 6 min read Like