# generate a list of Fibonacci numbers to a maximum value, show the last one, the count, and the list
{ object Fibonacci
private int fibs[] = [0, 1]
{ new (ulong maxFib) # constructor
{ do ulong n = fibs.lastIndex
ulong fn= fibs[n] + fibs[n-1] # next Fibonacci number
until fn > maxFib
n++
fibs[n] = fn
}
} # end constructor
{ method Report
ulong ndx = fibs.lastIndex, maxfn = fibs[ndx]
@ "The max Fibonacci produced is {maxfn}. The number of Fibocaccis is {fibs.Count}."
string FibList = fibs.join(', ')
@ "The Fibonacci numbers are: {FibList}."
}
} # end object def
{ object @Main
{ new # this constructor is the main program
@ "Fibonacci Program"
Fibonacci fibs = Fibonacci(500) # compute the numbers, up to the last one below 500
fibs.Report # result produced
# all done!
}
}