Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. Write code using any language (even pseudo code) that prints numbers from 1 to 100, but if the number is divisible by 5, print fizz. if it is divisible by 3, print buzz. if it is divisible by both 5 and 3, print fizzbuzz.
  2.  
  3. while (int i = 0; i <= 101; i++) {
  4. if ( i%5 = 0 && i%3 != 0) {
  5. system.out.println("fizz");
  6. }
  7. else if ( i%3 == 0 && i%5 != 0) {
  8. system.out.println("buzz");
  9. }
  10. else if ( i%3 == 0 && i%5 == 0) {
  11. system.out.println("fizzbuzz");
  12. }
  13. else {
  14. system.out.println(i);
  15. }
  16. x++;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement