Created
September 1, 2012 20:42
-
-
Save bittercoder/3586713 to your computer and use it in GitHub Desktop.
Monkey Coconuts Brute Force
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
namespace MonkeyCoconuts | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
for (int i=0; i<10000000; i++) | |
{ | |
if (test(i)) | |
{ | |
Console.WriteLine(i); | |
break; | |
} | |
} | |
Console.ReadLine(); | |
} | |
static bool test(int number) | |
{ | |
if ((number - 1) % 5 != 0) return false; | |
number = number - 1; | |
number = number - (number/5); | |
if ((number - 1) % 5 != 0) return false; | |
number = number - 1; | |
number = number - (number / 5); | |
if ((number - 1) % 5 != 0) return false; | |
number = number - 1; | |
number = number - (number / 5); | |
if ((number - 1) % 5 != 0) return false; | |
number = number - 1; | |
number = number - (number / 5); | |
if ((number - 1) % 5 != 0) return false; | |
number = number - 1; | |
number = number - (number / 5); | |
if ((number - 1) % 5 != 0) return false; | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment