Created
May 19, 2014 14:26
-
-
Save breyed/44861b168bcb57e6dc63 to your computer and use it in GitHub Desktop.
Faster checked arithmetic (with outer loop)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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