Jump to content

Hofstadter Q sequence: Difference between revisions

m
→‎{{header|REXX}}: added whitespace befor the FOR in a DO statement.
(Updated second D entry)
m (→‎{{header|REXX}}: added whitespace befor the FOR in a DO statement.)
Line 1,527:
HofstadterQ: procedure expose q.; arg x 1 ox /*get the # to gen through*/
/*(above) OX is the same as X.*/
x=abs(x) /*use the absolute value for X. */
L=length(x) /*use for right justified output.*/
do j=1 for x
if j>2 then if q.j==1 then do; jm1=j-1; jm2=j-2
_1=j-q.jm1; _2=j-q.jm2
Line 1,574:
x=abs(x) /*use the absolute value for X. */
L=length(x) /*use for right justified output.*/
do j=1 for x
if j>2 then if q.j==1 then q.j=q(j-q(j-1)) + q(j-q(j-2))
if ox>0 then say right(j,L) right(q.j,L) /*if X>0, tell*/
Cookies help us deliver our services. By using our services, you agree to our use of cookies.