Created
February 21, 2015 03:11
-
-
Save tnoda/17c0aaddf9c00adf79a4 to your computer and use it in GitHub Desktop.
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
(let [N (read-line) | |
digits (map #(Character/digit % 10) N) | |
m3 (rem (apply + digits) 3) | |
m5 (rem (last digits) 5) | |
answer (cond | |
(and (zero? m3) (zero? m5)) "Fizz Buzz" | |
(zero? m3) "Fizz" | |
(zero? m5) "Buzz" | |
:else N)] | |
(println answer)) |
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
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
var N string | |
fmt.Scan(&N) | |
var x, y int | |
for _, r := range N { | |
y = int(r - '0') | |
x += y | |
} | |
x %= 3 | |
y %= 5 | |
if x == 0 && y == 0 { | |
fmt.Println("Fizz Buzz") | |
return | |
} | |
if x == 0 { | |
fmt.Println("Fizz") | |
return | |
} | |
if y == 0 { | |
fmt.Println("Buzz") | |
return | |
} | |
fmt.Println(x, y) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment