26 lines
736 B
Text
26 lines
736 B
Text
q_seq = proc (n: int) returns (sequence[int])
|
|
q: array[int] := array[int]$[1,1]
|
|
for i: int in int$from_to(3,n) do
|
|
array[int]$addh(q, q[i-q[i-1]] + q[i-q[i-2]])
|
|
end
|
|
return(sequence[int]$a2s(q))
|
|
end q_seq
|
|
|
|
start_up = proc ()
|
|
po: stream := stream$primary_output()
|
|
|
|
q: sequence[int] := q_seq(100000)
|
|
stream$puts(po, "First 10 terms:")
|
|
for i: int in int$from_to(1,10) do
|
|
stream$puts(po, " " || int$unparse(q[i]))
|
|
end
|
|
|
|
stream$puts(po, "\n1000th term: " || int$unparse(q[1000]))
|
|
|
|
flips: int := 0
|
|
for i: int in int$from_to(2, sequence[int]$size(q)) do
|
|
if q[i-1]>q[i] then flips := flips + 1 end
|
|
end
|
|
|
|
stream$putl(po, "\nflips: " || int$unparse(flips))
|
|
end start_up
|