RosettaCodeData/Task/Fusc-sequence/00-TASK.txt

48 lines
1.9 KiB
Plaintext

;Definitions:
The   '''fusc'''   integer sequence is defined as:
::*   fusc(0) = 0
::*   fusc(1) = 1
::* &nbsp; for '''n'''>1, &nbsp; the &nbsp; '''n'''<sup>th</sup> &nbsp; term is defined as:
::::* &nbsp; if &nbsp; '''n''' &nbsp; is even; &nbsp; &nbsp; fusc(n) = fusc(n/2)
::::* &nbsp; if &nbsp; '''n''' &nbsp; is &nbsp; odd; &nbsp; &nbsp; fusc(n) = fusc<big>(</big>(n-1)/2<big>)</big> &nbsp; <big>+</big> &nbsp; fusc<big>(</big>(n+1)/2<big>)</big>
Note that MathWorld's definition starts with unity, not zero. &nbsp; This task will be using the OEIS' version &nbsp; (above).
;An observation:
:::::* &nbsp; fusc(A) = fusc(B)
where &nbsp; '''A''' &nbsp; is some non-negative integer expressed in binary, &nbsp; and
where &nbsp; '''B''' &nbsp; is the binary value of &nbsp; '''A''' &nbsp; reversed.
Fusc numbers are also known as:
::* &nbsp; fusc function &nbsp; (named by Dijkstra, 1982)
::* &nbsp; Stern's Diatomic series &nbsp; (although it starts with unity, not zero)
::* &nbsp; Stern-Brocot sequence &nbsp; (although it starts with unity, not zero)
;Task:
::* &nbsp; show the first &nbsp; '''61''' &nbsp; fusc numbers (starting at zero) in a horizontal format.
::* &nbsp; show the fusc number (and its index) whose length is greater than any previous fusc number length.
::::* &nbsp; (the length is the number of decimal digits when the fusc number is expressed in base ten.)
::* &nbsp; show all numbers with commas &nbsp; (if appropriate).
::* &nbsp; show all output here.
;Related task:
:* &nbsp; [[Stern-Brocot sequence]]
:* &nbsp; [[Calkin-Wilf sequence]].
<!-- This is similar as "generate primes by trial division", and "generate primes via a sieve". Both Rosetta Code tasks have their uses and methods of generation. !~-->
;Also see:
::* &nbsp; the MathWorld entry: &nbsp; [http://mathworld.wolfram.com/SternsDiatomicSeries.html Stern's Diatomic Series].
::* &nbsp; the OEIS entry: &nbsp; [http://oeis.org/A2487 A2487].
<br><br>