LeetCode/go/2-keys-keyboard.go

15 lines
145 B
Go
Raw Normal View History

package main
func minSteps(n int) int {
steps := 0
for d := 2; n > 1; d++ {
for n%d == 0 {
steps += d
n /= d
}
}
return steps
}