Last active
December 31, 2018 19:41
-
-
Save gegen07/ba245251bae745d465483eda848b9b99 to your computer and use it in GitHub Desktop.
A program to append the pisano period into an array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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