My 153 character long formula dynamically constructs a 2d array that is just large enough to check if the particular number is a prime.
So:
If I’m checking 10, then my formula constructs this 2D array:
[pre]
Code:
1 2
3 4
If I’m checking 100, then my formula constructs this 2D array:
[pre][code]1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
If I’m checking 1000, then my formula constructs this 2D array:
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24
25 26 27 28 29 30
31 32 33 34 35 36
[/pre]
And if I’m checking 10000, then my formula constructs this 2D array:
1 2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 17 18 19 20 21 22
23 24 25 26 27 28 29 30 31 32 33
34 35 36 37 38 39 40 41 42 43 44
45 46 47 48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63 64 65 66
67 68 69 70 71 72 73 74 75 76 77
78 79 80 81 82 83 84 85 86 87 88
89 90 91 92 93 94 95 96 97 98 99
100 101 102 103 104 105 106 107 108 109 110
111 112 113 114 115 116 117 118 119 120 121[/code][/pre]
If you can work out how to produce these arrays, then you've all-but solved the challenge.
Note that these arrays are slightly longer than I need to check for primality. But only by a whisker.
Given that the size of the array corresponds to the size of the number I’m checking, small to medium numbers takes no time at all. Checking very large numbers – such as 122,816,065,582,079 – takes three to five seconds.
The biggest number I’ve managed to check so far is 202,005,700,000,123 but I often have to restart Excel to check the next number at that size.