Hofstadter Figure-Figure sequences: Difference between revisions

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

edits