Element integer_addition = ?primitives/integer_addition
Element integer_gt = ?primitives/integer_gt
Element list_len = ?primitives/list_len
Element list_append = ?primitives/list_append
Element integer_subtraction = ?primitives/integer_subtraction
Element dict_read = ?primitives/dict_read
Element create_node = ?primitives/create_node

Element numbers = ?

include "io.alh"

Integer function fib(param : Integer):
	Integer new
	while (integer_gt(param, list_len(numbers))):
		new = list_len(numbers)
		list_append(numbers, integer_addition(dict_read(numbers, integer_subtraction(new, 2)), dict_read(numbers, integer_subtraction(new, 1))))
	return dict_read(numbers, integer_subtraction(param, 1))!

Void function main():
	numbers = create_node()
	list_append(numbers, 1)
	list_append(numbers, 1)
	while(True):
		output(fib(input()))
