Consider a sequence F
of positive integers where F(n) = F(n-1) + F(n-2)
for n >= 2
. The Fibonacci sequence is almost one example of this type of sequence for F(0) = 0, F(1) = 1
, but it's excluded because of the positive integer requirement. Any two initial values will yield a different sequence. For example F(0) = 3, F(1) = 1
produces these terms.
3, 1, 4, 5, 9, 14, 23, 37, 60, 97, ...
Challenge
The task is to find F(0)
and F(1)
that minimize F(0) + F(1)
given some term of a sequence F(n)
. Write a function or complete program to complete the task.
Input
Input is a single positive integer, F(n)
. It may be accepted as a parameter or from standard input. Any reasonable representation is allowed, including direct integer or string representations.
Invalid inputs need not be considered.
Output
The output will be two positive integers, F(0)
and F(1)
. Any reasonable format is acceptable. Here are some examples of reasonable formats.
- Written on separate lines to standard output
- Formatted on standard output as a delimited 2-element list
- Returned as a tuple or 2-element array of integers from a function
Examples
60 -> [3, 1]
37 -> [3, 1]
13 -> [1, 1]
26 -> [2, 2]
4 -> [2, 1]
5 -> [1, 1]
6 -> [2, 2]
7 -> [2, 1]
12 -> [3, 2]
1 -> [1, 1]
Scoring
This is code golf. The score is calculated by bytes of source code.
12 -> [4, 0]
count? \$\endgroup\$F
is a sequence of positive integers, and 0 isn't positive, so that's not valid. \$\endgroup\$