Here is what I'm supposed to do:
Write a program that reads a positive integer and displays the maximum positive integer n for which the sum 1^2 + 2^2 + 3^2 + ... + n^2 is less than the given number.
So far I am only able to just add the sum of all natural numbers until n:
#include <stdio.h>
int main ()
{
unsigned int n;
int sum = 0;
int i;
sum = 0;
printf("Print your number");
scanf("%d", &n);
for (i = 1; i <= n; ++i)
{
sum += i;
}
printf("sum = %d", sum);
return 0;
}
Appreciate the help!