lucassequence.a68
1 #
2
3 @section Synopsis
4
5 Lucas sequence and the golden ratio.
6
7 The Lucas sequence has the same recursive relationship as the Fibonacci sequence.
8 The ratio of successive terms approaches the golden ratio, the terms themselves being
9 roundings of integer powers of the golden ratio. Two numbers are in the golden ratio
10 if their ratio equals the ratio of their sum to the larger of the two numbers:
11
12 (a + b) / a = a / b, with a > b > 0.
13
14 #
15
16 CO Using refinements CO
17
18 determine first generation;
19 WHILE can represent next generation
20 DO calculate next generation;
21 print next generation
22 OD.
23
24 determine first generation:
25 LONG INT previous := 1, current := 3.
26
27 can represent next generation:
28 current <= long max int  previous.
29
30 calculate next generation:
31 LONG INT new = current + previous;
32 previous := current;
33 current := new.
34
35 print next generation:
36 print ((current, newline, previous, new line, current / previous, new line, new line)).
© 20022024 J.M. van der Veer (jmvdveer@xs4all.nl)
