Van Eck sequence: Difference between revisions

Content added Content deleted
m (fmt)
(Added Go)
Line 40:
;Reference:
* [https://www.youtube.com/watch?v=etMJxB-igrc Don't Know (the Van Eck Sequence) - Numberphile video].
 
=={{header|Go}}==
<lang go>package main
 
import "fmt"
 
func main() {
const max = 1000
a := make([]int, max) // all zero by default
a[0] = 0
for n := 0; n < max-1; n++ {
for m := n - 1; m >= 0; m-- {
if a[m] == a[n] {
a[n+1] = n - m
break
}
}
}
fmt.Println("The first ten terms of the Van Eck sequence are:")
fmt.Println(a[:10])
fmt.Println("\nTerms 991 to 1000 of the sequence are:")
fmt.Println(a[990:])
}</lang>
 
{{out}}
<pre>
The first ten terms of the Van Eck sequence are:
[0 0 1 0 2 0 2 2 1 6]
 
Terms 991 to 1000 of the sequence are:
[4 7 30 25 67 225 488 0 10 136]
</pre>
 
=={{header|Python}}==