go: add «650. 2 Keys Keyboard»
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
970869babd
commit
5632842740
1 changed files with 14 additions and 0 deletions
14
go/2-keys-keyboard.go
Normal file
14
go/2-keys-keyboard.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
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
|
||||
}
|
Loading…
Reference in a new issue