We all know about the Fibonacci sequence. We start with two 1s and keep getting the next element with the sum of previous two elements.
n-bonacci sequence can be defined in similar way, we start with n
1s and take the sum of previous n
elements to get the next element.
Challenge
Given a positive integer m
> 1, output the smallest n
of the n-bonacci sequence that contains m
, and the index of m
in that sequence (either 0 or 1 indexed).
There should be two integers in output, one will be which n-bonacci sequence the number is in, and another for the 0 or 1-indexed index in it.
I/O is flexible, you may choose to output either list, string or two numbers with optional trailing whitespace.
Test cases
First integer is which n-bonacci sequence and second is 0-indexed position:
2 -> 2,2
3 -> 2,3
4 -> 4,4
5 -> 2,4
6 -> 6,6
7 -> 4,5
8 -> 2,5
9 -> 3,5
10 -> 10,10
11 -> 6,7
12 -> 12,12
13 -> 2,6
14 -> 14,14
15 -> 8,9
16 -> 16,16
17 -> 3,6
18 -> 18,18
19 -> 10,11
20 -> 20,20
21 -> 2,7
22 -> 22,22
23 -> 12,13
24 -> 24,24
25 -> 4,7
26 -> 26,26
27 -> 14,15
28 -> 28,28
29 -> 8,10
30 -> 30,30
31 -> 3,7
32 -> 32,32
33 -> 5,8
34 -> 2,8
35 -> 18,19
36 -> 36,36
37 -> 10,12
38 -> 38,38
39 -> 20,21
40 -> 40,40
41 -> 6,9
42 -> 42,42
43 -> 22,23
44 -> 44,44
45 -> 12,14
46 -> 46,46
47 -> 24,25
48 -> 48,48
49 -> 4,8
50 -> 50,50
51 -> 26,27
52 -> 52,52
53 -> 14,16
54 -> 54,54
55 -> 2,9
56 -> 56,56
57 -> 3,8
58 -> 58,58
59 -> 30,31
60 -> 60,60
61 -> 16,18
62 -> 62,62
63 -> 32,33
64 -> 64,64
65 -> 5,9
66 -> 66,66
67 -> 34,35
68 -> 68,68
69 -> 18,20
This is code-golf so shortest answer wins.