Skip to content

Instantly share code, notes, and snippets.

@caesaneer
Created August 14, 2019 22:40
Show Gist options
  • Save caesaneer/b15d0efe161a15eeb519294d210e3a8c to your computer and use it in GitHub Desktop.
Save caesaneer/b15d0efe161a15eeb519294d210e3a8c to your computer and use it in GitHub Desktop.
Loop with Fibonacci Sequence
func fibonacci() []int {
var result []int
var start = 1000
for {
var num = 1250
var n1, n2, temp int = 0, 1, 0
for {
temp = n2
n2 = n1 + n2
n1 = temp
result = append(result, n2)
if num <= 1 {
break
}
num--
}
if start <= 1 {
break
}
start--
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment