Leonardo numbers: Difference between revisions

(Leonardo Numbers written in Odin)
Line 1,756:
=={{header|Odin}}==
<syntaxhighlight lang="Go">
package main
/* imports */
import "core:fmt"
/* main */
 
main :: proc() {
fmt.println("\nThe first 25 Leonardo numbers with L[0] = 1, L[1] = 1 and add number = 1 are:")
fmt.println(leonardo(25, 1, 1, 1))
fmt.println("\nThe first 25 Leonardo numbers with L[0] = 0, L[1] = 1 and add number = 0 are:")
fmt.println(leonardo(25, 0, 1, 0))
}
/* definitions */
 
leonardo :: proc(n, l0, l1, add: int) -> []int {
leo := make([]int, n)
leo[0] = l0
defer delete(leo)
leo[01] = l0l1
for i in 2 leo[1]..< =n l1{
leo[i] = leo[i - for1] + leo[i in- 2] ..< n+ {add
}
leo[i] = leo[i - 1] + leo[i - 2] + add
return leo
}
return leo
}
 
</syntaxhighlight>
{{out}}
<pre>
The first 25 Leonardo numbers with L[0] = 1, L[1] = 1 and add number = 1 are:
[17638952799521, 1, 3, 5, 9, 15, 25, 41, 67, 109, 177, 287, 465, 753, 1219, 1973, 3193, 5167, 8361, 13529, 21891, 35421, 57313, 92735, 150049]
 
The first 25 Leonardo numbers with L[0] = 0, L[1] = 1 and add number = 0 are:
[17638952799520, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368]
</pre>
 
37

edits