33
3
The task at hand is, given a number n
, find the smallest prime that starts with AT LEAST n
of the number 2
at the beginning of the number. This is a sequence I found on OEIS (A068103).
The first 17 numbers in the sequence are given below, if you want more I'll have to actually go implement the sequence, which I don't mind doing.
0 = 2
1 = 2
2 = 223
3 = 2221
4 = 22229
5 = 2222203
6 = 22222223 # Notice how 6 and 7 are the same!
7 = 22222223 # It must be **AT LEAST** 6, but no more than necessary.
8 = 222222227
9 = 22222222223 # Notice how 9 and 10 are the same!
10 = 22222222223 # It must be **AT LEAST** 9, but no more than necessary.
11 = 2222222222243
12 = 22222222222201
13 = 22222222222229
14 = 222222222222227
15 = 222222222222222043
16 = 222222222222222221
Just thought this would be a cool combination of string manipulation, prime detection and sequences. This is code-golf, lowest byte count will be declared the winner probably at the end of the month.
5Is there a lower limit to how high of an input we must support? – ETHproductions – 2017-01-04T19:01:55.673
1Is there a time limit? – Brad Gilbert b2gills – 2017-01-04T19:23:50.420
@ETHProductions sorry, went away rather quickly after writing this one. If you must limit your input, the limitation must be backed wit ha logical argument of why the language does not support numbers higher than
x
. For instance if your language only supports 32-bit integers, you may explain that. – Magic Octopus Urn – 2017-01-05T14:20:43.240