Hofstadter Figure-Figure sequences: Difference between revisions
Content added Content deleted
m (→version 1: added some comments.) |
(Restoring visibility of task description formulae (hidden by under-tested cosmetic edits of 18:19, 28 August 2016)) |
||
Line 2: | Line 2: | ||
These two sequences of positive integers are defined as: |
These two sequences of positive integers are defined as: |
||
:::: |
:::: <big><math>\begin{align} |
||
R(1)&=1\ ;\ S(1)=2 \\ |
|||
R(n)&=R(n-1)+S(n-1), \quad n>1. |
|||
⚫ | |||
R(n)&=R(n-1)+S(n-1), \quad n>1. |
|||
⚫ | |||
<br> |
<br> |
||
The sequence |
The sequence <big><math>S(n)</math></big> is further defined as the sequence of positive integers '''''not''''' present in <big><math>R(n)</math></big>. |
||
Sequence |
Sequence <big><math>R</math></big> starts: |
||
1, 3, 7, 12, 18, ... |
1, 3, 7, 12, 18, ... |
||
Sequence |
Sequence <big><math>S</math></big> starts: |
||
2, 4, 5, 6, 8, ... |
2, 4, 5, 6, 8, ... |
||
;Task: |
;Task: |
||
# Create two functions named |
# Create two functions named '''ffr''' and '''ffs''' that when given '''n''' return '''R(n)''' or '''S(n)''' respectively.<br>(Note that R(1) = 1 and S(1) = 2 to avoid off-by-one errors). |
||
# No maximum value for |
# No maximum value for '''n''' should be assumed. |
||
# Calculate and show that the first ten values of |
# Calculate and show that the first ten values of '''R''' are:<br> 1, 3, 7, 12, 18, 26, 35, 45, 56, and 69 |
||
# Calculate and show that the first 40 values of |
# Calculate and show that the first 40 values of '''ffr''' plus the first 960 values of '''ffs''' include all the integers from 1 to 1000 exactly once. |
||