Hofstadter Figure-Figure sequences: Difference between revisions
Content added Content deleted
m (→{{header|Sidef}}: modified the code to work with Sidef 2.30) |
m (added whitespace before the TOC (table of contents), added a ;Task: (bold) header.) |
||
Line 1: | Line 1: | ||
{{task}} |
{{task}} |
||
These two sequences of positive integers are defined as: |
These two sequences of positive integers are defined as: |
||
:<math>\begin{align} |
:<math>\begin{align} |
||
Line 9: | Line 10: | ||
Sequence S starts: 2, 4, 5, 6, 8, ... |
Sequence S starts: 2, 4, 5, 6, 8, ... |
||
Task: |
;Task: |
||
# Create two functions named ffr and ffs that when given n return R(n) or S(n) respectively.<br><small>(Note that R(1) = 1 and S(1) = 2 to avoid off-by-one errors).</small> |
# Create two functions named ffr and ffs that when given n return R(n) or S(n) respectively.<br><small>(Note that R(1) = 1 and S(1) = 2 to avoid off-by-one errors).</small> |
||
# No maximum value for n should be assumed. |
# No maximum value for n should be assumed. |
||
Line 19: | Line 21: | ||
* [http://mathworld.wolfram.com/HofstadterFigure-FigureSequence.html Wolfram Mathworld] |
* [http://mathworld.wolfram.com/HofstadterFigure-FigureSequence.html Wolfram Mathworld] |
||
* Wikipedia: [[wp:Hofstadter_sequence#Hofstadter_Figure-Figure_sequences|Hofstadter Figure-Figure sequences]]. |
* Wikipedia: [[wp:Hofstadter_sequence#Hofstadter_Figure-Figure_sequences|Hofstadter Figure-Figure sequences]]. |
||
<br><br> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
Specifying a package providing the functions FFR and FFS: |
Specifying a package providing the functions FFR and FFS: |