1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-14 01:49:41 +01:00
LeetCode/go/find-the-winner-of-the-circular-game.go
2024-07-08 13:52:37 +02:00

11 lines
147 B
Go

package main
func findTheWinner(n int, k int) int {
winner := 0
for i := 2; i <= n; i++ {
winner = (winner + k) % i
}
return winner + 1
}