Skip to main content
Tweeted twitter.com/StackCodeGolf/status/675695839713603585
edited tags
Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975
Source Link
Adnan
  • 44.5k
  • 6
  • 82
  • 246

Find the nth Fibohexaprime

The challenge this time is to find the nth Fibohexaprime. The definition of a Fibohexaprime is as following:

We first observe a list with Fibonacci numbers:

N  | Fibonacci number
1  | 1 
2  | 1 
3  | 2 
4  | 3 
5  | 5 
6  | 8 
7  | 13 
8  | 21 
9  | 34 
10 | 55 
11 | 89 
12 | 144 
13 | 233 
14 | 377 
15 | 610
16 | 987 
17 | 1597

After that, we convert the numbers to hexadecimal:

N  | Fib  | Hex 
1  | 1    | 1
2  | 1    | 1
3  | 2    | 2
4  | 3    | 3
5  | 5    | 5
6  | 8    | 8
7  | 13   | D
8  | 21   | 15
9  | 34   | 22
10 | 55   | 37
11 | 89   | 59
12 | 144  | 90
13 | 233  | E9
14 | 377  | 179
15 | 610  | 262
16 | 987  | 3DB
17 | 1597 | 63D

From the hexadecimal numbers, we filter out the letters. All we are left with are numbers. We need to check if these numbers are prime:

hex |  filtered |  is prime? |  N =
1   >  1        >  false
1   >  1        >  false
2   >  2        >  true         1
3   >  3        >  true         2
5   >  5        >  true         3
8   >  8        >  false
D   >  0        >  false
15  >  15       >  false
22  >  22       >  false
37  >  37       >  true         4
59  >  59       >  true         5
90  >  90       >  false
E9  >  9        >  false
179 >  179      >  true         6
262 >  262      >  false
3DB >  3        >  true         7
63D >  63       >  false

If the filtered number is a prime, we call this a Fibohexaprime. You can see that for N = 7, the related fibonacci number is 987.

The task is simple, when given an input using STDIN or an acceptable alternative, write a program or a function which outputs the nth Fibohexaprime using STDOUT or an acceptable alternative.

Test cases

Input - Output
1     - 2
2     - 3
3     - 5
4     - 55
5     - 89
6     - 377
7     - 987
8     - 28657
9     - 75025
10    - 121393
11    - 317811
12    - 5702887
13    - 9227465
14    - 39088169
15    - 102334155
16    - 32951280099
17    - 4052739537881
18    - 806515533049393
19    - 7540113804746346429

The rules:

  • Given an integer between 1 and 19 (the values above 20 exceed the max value for a 64-bit signed integer), output the corresponding value.
  • You may write a function or a program.
  • This is , so the submission with the least amount of bytes wins!