Skip to content

Instantly share code, notes, and snippets.

@lrlucena
Forked from adolfont/fizzbuzz.poti
Last active November 20, 2018 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrlucena/2fcba1c73402ec377edb8eb6cd74eab8 to your computer and use it in GitHub Desktop.
Save lrlucena/2fcba1c73402ec377edb8eb6cd74eab8 to your computer and use it in GitHub Desktop.
fizz(numero: Inteiro) = escolha numero
caso n se n mod 3 == 0 => "fizz"
caso _ => "{numero}"
fim
buzz(numero: Inteiro) = escolha numero
caso n se n mod 5 == 0 => "buzz"
caso _ => "{numero}"
fim
fizzbuzz_aux(numero: Inteiro) = escolha numero
caso n se n mod 5 == 0 => "buzz"
caso _ => fizz(numero)
fim
fizzbuzz(numero: Inteiro) = escolha numero
caso n se n mod 15 == 0 => "fizzbuzz"
caso _ => fizzbuzz_aux(numero)
fim
fizzbuzz2(numero: Inteiro) = escolha numero
caso n se n mod 15 == 0 => "fizzbuzz"
caso n se n mod 5 == 0 => "buzz"
caso n se n mod 3 == 0 => "fizz"
caso _ => "{numero}"
fim
fizzbuzz3(numero: Inteiro) = escolha (numero mod 3, numero mod 5)
caso (0, 0) => "fizzbuzz"
caso (0, _) => "fizz"
caso (_, 0) => "buzz"
caso _ => "{numero}"
fim
para i de 1 até 30 faça
escreva fizzbuzz(i)
fim
para i de 1 até 10 faça
escreva "fizz de {i} é {fizz(i)}"
fim
para i de 1 até 10 faça
escreva "buzz de {i} é {buzz(i)}"
fim
para i de 1 até 30 faça
escreva "fizzbuzz de {i} é {fizzbuzz(i)}"
fim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment