exercism/go/raindrops/raindrops.go

27 lines
416 B
Go
Raw Normal View History

2016-08-13 23:20:14 +00:00
package raindrops
import "fmt"
// TestVersion
const TestVersion = 1
// Convert takes a number and returns Raindrop-speak
func Convert(i int) string {
var ret string
if i%3 == 0 {
ret += "Pling"
}
if i%5 == 0 {
ret += "Plang"
}
if i%7 == 0 {
ret += "Plong"
}
if ret != "" {
return ret
}
return fmt.Sprintf("%d", i)
}
// The test program has a benchmark too. How fast does your Convert convert?