Skip to content

Instantly share code, notes, and snippets.

@gegen07
Last active December 31, 2018 19:41
Show Gist options
  • Save gegen07/ba245251bae745d465483eda848b9b99 to your computer and use it in GitHub Desktop.
Save gegen07/ba245251bae745d465483eda848b9b99 to your computer and use it in GitHub Desktop.
A program to append the pisano period into an array
func getPisanoPeriodFast(n int) []int {
var period []int
period = append(period, 0, 1)
var remainder int
for index := 0; index < n*n; index++ {
remainder = (period[index] + period[index+1]) % n
if remainder == 1 && period[index+1] == 0 {
return period[:index+1]
}
period = append(period, remainder)
}
return period
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment