Interview Questions: Write programs to do the following.





  • Check for a Perfect Number 
    • A perfect number is a number that is equal to the sum of its proper divisors. Eg 6 is a perfect number because its proper divisors are 1, 2 and 3 where 1+2+3=6. Another perfect number is 28.
  • Check for an Armstrong Number
    • An Armstrong Number is equal to the sum of the cubes of its digits. Eg  153 has the digits 1, 5 and 3. 13 + 53 + 33 = 1 + 125 + 27= 153
  • Check for a Happy Number
    • A Happy Number is a number that finally reaches 1 when replaced continuously by the sum of the square of its digits. Eg 19 = 12 + 92 = 82 = 82 + 22 = 68 = 62 + 82 = 100 = 12 + 02 + 02 = 1.
  • Check for a Prime Number
    • Everybody knows what a prime number is
  • Check if a number is a perfect cube

Post a Comment

0 Comments