[update] Understanding why for n=1;n+2 ((n^2)-1)%8==0 isn't the point of this exercise...look at the pattern in the results of each iteration. That's what has me baffled. Haacked has a great proof explaining what's going on on the left side of the operand, but I'm more interested in what's up with the right side. [/update]
This just popped into my head the other day for no other reason than to bug me: Square all odd numbers starting with 1…subtract 1 from the result…then divide by 8. Now look for the pattern in the results.
for (int i = 1; i < 100; i += 2)
{
int iSquared = (i * i);
if (((iSquared) - 1) % 8 == 0)
{
int result = ((iSquared - 1) / 8);
Console.WriteLine(i + "^2 = " + iSquared + " - 1 = " + ((iSquared) - 1) + " / 8 = " + result);
}
else
{
Console.WriteLine("false");
}
}
Console.ReadLine();
Squint for a second or 2 and you’ll see it. Anyone out there with a degree in mathematics care to explain why that happens?
Share this post: 
|

|

|

|

|
