efficiency of using this method of stepping through primes:
l=1 : 100%
l=2 : 50%
l=6 : 33%
l=30 : 27%
l=210 : 20% 2*3*5*7
l=2310: 15% 2*3*5*7*11
....
//
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67
+1 +2 +2 +4 +2 +4 +2 +4 +6 +2 +6 +4 +2 +4 +6 +6 +2 +6
start = primes upto p
total span of step = product of primes upto (excluding) p
long start[]={2, 3, 5, 7};
long step[]={ 4 ,2 ,4 ,2 ,4 ,6 ,2 ,6 };
l=1
test all numbers: 2, 3, 4, 5, 6, 7, 8, .....
l=2
(most commonly used)
start your prime list with 2
and test all odd numbers: 3, 5, 7, 9, 11, ....
2 3 : 5 7 . 11 13 . 17 19 . 23 . . 29 31 . . 37 . 41 43 . 47 . . 53 . . 59 61 . . 67 . 71
+1 :+2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2
- "." means number tested which is not a prime
l=6
start your prime list with 2, 3
and test starting from 5, with alternating steps 2, and 4:
7, 11, 13, 17, 19, 23, 25, 29, ...
2 3 5 : 7 11: 13 17: 19 23: . 29: 31 .: 37 41: 43 47: . 53: . 59: 61 .: 67 71
+1 +2 :+2 +4 :+2 +4 :+2 +4 :+2 +4 :+2 +4 :+2 +4 :+2 +4 :+2 +4 :+2 +4 :+2 +4 :+2 +4
l=30
start your prime list with 2, 3, 5
and test starting from 7, with alternating steps of: +4 +2 +4 +2 +4 +6 +2 +6
2 3 5 7 : 11 13 17 19 23 29 31 37: 41 43 47 . 53 59 61 67: 71 73 . 79 83 89 . 97: 101 103 107 109 113 . . 127:131 137 139
+1 +2 +2 :+4 +2 +4 +2 +4 +6 +2 +6 :+4 +2 +4 +2 +4 +6 +2 +6 :+4 +2 +4 +2 +4 +6 +2 +6 :+4 +2 +4 +2 +4 +6 +2 +6 :
l=210
2 3 5 7 11: 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211
1 2 2 4 :2 4 2 4 6 2 6 4 2 4 6 6 2 6 4 2 6 4 6 8 4 2 4 2 4 14 4 6 2 10 2 6 6 4 6 6 2 10 2 4 2 12 6