Skip to content

Instantly share code, notes, and snippets.

@breyed
Created May 19, 2014 14:26
Show Gist options
  • Save breyed/44861b168bcb57e6dc63 to your computer and use it in GitHub Desktop.
Save breyed/44861b168bcb57e6dc63 to your computer and use it in GitHub Desktop.
Faster checked arithmetic (with outer loop)
using System;
using System.Diagnostics;
class Program
{
static void Main(string[] args)
{
var s = new Stopwatch();
s.Start();
var outerSum = 0;
for (int outerIndex = 0; outerIndex < 20; ++outerIndex) {
int a = 0;
for (int i = 0; i < 100000000; i += 3) {
if (i == 1000)
i *= 2;
if (i % 35 == 0)
++a;
}
outerSum += a;
}
s.Stop();
Console.WriteLine(s.ElapsedMilliseconds);
Console.WriteLine(outerSum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment