#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int x=0;
int y=0;
while (x<15)y++,x+=++y;
printf ("%i %i",x, y);
getchar ();
getchar ();
return 0;
}
I don’t know why x is 20 and y is 8 at the end.
Please explain it step by step.
=>
=>
So:
Note that there is a simple closed formula for these values as well:
x = n*n - nandy = 2*n.