Ulam numbers: Difference between revisions

m
→‎{{header|REXX}}: added whitespace, split a line.
(Added Sidef)
m (→‎{{header|REXX}}: added whitespace, split a line.)
Line 1,020:
th: parse arg th; return word('th st nd rd', 1 + (th//10)*(th//100%10\==1)*(th//10<4))
/*──────────────────────────────────────────────────────────────────────────────────────*/
Ulam: parse arg n; @.1= 1; @.2= 2; #= 2 /*1st two terms; #: sequence length. */
!.= 0; !.1= 1; !.2=1 1 /*semaphore for each term in sequence. */
z= 3 /*value of next possible term in seq. */
do until #==n
Line 1,032:
 
if cnt==2 then do; #= # + 1 /*bump the number of terms. */
@.#= z; !.z= 1 /*add Z to sequence;the boolsequence. */
!.z= 1 /*set the semaphore for Z. */
end
z= z + 1 /*bump next possible term. */