Menu
Coddy logo textTech

Number of Squares

Lesson 8 of 15 in Coddy's Recursion Challenges - Master The Recursive Thinking course.

challenge icon

Challenge

Medium

Write a function named squareNum that gets an integer n and returns the minimum number of squares that sums to n.

Examples,

  • n=9  ->  9 = 32  ->  1
  • n=10  ->  10=32+12  ->  2
  • n=63  ->  63=72+32+22+12  ->  4

Try it yourself

int squareNum(int n) {
    // Write code here
}

All lessons in Recursion Challenges - Master The Recursive Thinking