General FizzBuzz: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 820: | Line 820: | ||
1 2 F 4 B F G 8 F B 11 F 13 G FB 16 17 F 19 B FG 22 23 F B 26 F G 29 FB 31 32 F 34 BG F 37 38 F B |
1 2 F 4 B F G 8 F B 11 F 13 G FB 16 17 F 19 B FG 22 23 F B 26 F G 29 FB 31 32 F 34 BG F 37 38 F B |
||
</pre> |
</pre> |
||
=={{header|Go}}== |
|||
<lang Go> |
|||
package main |
|||
import ( |
|||
"fmt" |
|||
) |
|||
const numbers = 3 |
|||
func main() { |
|||
//using the provided data |
|||
max := 20 |
|||
words := map[int]string{ |
|||
3: "Fizz", |
|||
5: "Buzz", |
|||
7: "Baxx", |
|||
} |
|||
keys := []int{3, 5, 7} |
|||
divisible := false |
|||
for i := 1; i <= max; i++ { |
|||
for _, n := range keys { |
|||
if i % n == 0 { |
|||
fmt.Print(words[n]) |
|||
divisible = true |
|||
} |
|||
} |
|||
if !divisible { |
|||
fmt.Print(i) |
|||
} |
|||
fmt.Println() |
|||
divisible = false |
|||
} |
|||
}</lang> |
|||
=={{header|Groovy}}== |
=={{header|Groovy}}== |