PHP Coding Interview Question Practice On Integer

  • Last updated: October 3, 2024 By Sunil Shaw

  1. Write a PHP function that takes an integer n and returns the sum of all integers from 1 to n.
  2. Write a function to calculate the factorial of a given integer n.
  3. Write a function that takes an integer and returns whether it is even or odd.
  4. Write a PHP function that takes an integer and returns the integer with its digits reversed.
  5. Write a function that takes an integer and returns true if it is a prime number and false otherwise.
  6. Write a function that takes an integer and returns the sum of its digits.
  7. Write a function to find the GCD of two integers using the Euclidean algorithm.
  8. Write a function to check if a given integer is a palindrome (e.g., 121 is a palindrome, 123 is not).
  9. Write a function that takes an integer and returns how many divisors it has.
  10. Write a function that takes an array of integers and returns the maximum number.
  11. Write a function to generate the first n numbers in the Fibonacci sequence.
  12. Write a function that checks whether a number is an Armstrong number (e.g., 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153).
  13. Write a function to calculate x^y (x raised to the power of y) for two given integers x and y.
  14. Write a function that returns the sum of all even numbers from 1 to n.
  15. Write a function that takes an array of integers and returns the median.
  16. Write a function that takes an integer n and generates a multiplication table up to n * 10.
  17. Write a function to return the sum of the first n odd numbers.
  18. Write a function to check if a given number is a perfect number (a number that is equal to the sum of its divisors, excluding itself).
  19. Write a function that takes an array of integers and returns the minimum number.
  20. Write a function that takes an integer and returns the largest digit in that number.


Follow on:
  • Twitter
  • Facebook
  • Instagram
  • Linkedin
  • Linkedin
Sunil Shaw

Sunil Shaw

  • Youtube
  • Instagram
  • Twitter
  • Facebook
About Author

I am a Web Developer, Love to write code and explain in brief. I Worked on several projects and completed in no time.

Popular Language Tutorials

If You want to build your own site Contact Us