Skip to content

Instantly share code, notes, and snippets.

@posaunehm
Created April 11, 2012 14:12
Show Gist options
  • Save posaunehm/2359539 to your computer and use it in GitHub Desktop.
Save posaunehm/2359539 to your computer and use it in GitHub Desktop.
Calculate summation for 1 - 100 using only one valurable
int x = 100;
while((x & 255) != 0)
{
x += ((x & 255) << 8);
x--;
}
Console.WriteLine(x >> 8);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment