Challenge (w/ Recursion)

After successfully completing the challenge I decided to take it another step. I attempted to add recursion so the program would start squaring at 0 and continually increase by 1 and compute. After a few minutes of tinkering I finally got a successful compile. The computations are correct from 0 until it reaches 46341. Suddenly the computations turn negative and begin to increase. Eventually it seems I get an error at 262022 squared. I have tried changing some of the variable types and that makes all the computations incorrect. Any advise to what it is causing these errors to occur. I am very new to coding and would appreciate any guidance or adviseā€¦Thanks!

[code]#include <stdio.h>
#include <unistd.h>

void squared (int squarer)

int solution = squarer*squarer;
printf("\"%d\" squared is \"%d\".\n", squarer, solution);
int plusOne = squarer +1;
squared (plusOne);

int main(int argc, const char * argv[])

return 0;

Good try, but you need to terminate the recursion. Otherwise, your program will eventually crash.

Try this instead:

typedef unsigned long number_type;

const number_type LIMIT = 10 * 1024;

void squared (const number_type number)
    if (number > LIMIT) {
    const number_type result = number * number;
    printf ("\"%lu\" squared is \"%lu\".\n", number, result);
    const number_type nextNumber = number + 1;
    squared (nextNumber);