52 lines
1.1 KiB
Python
52 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""MK-DAA-Rasya-Alfahrizi.ipynb
|
|
|
|
Automatically generated by Colab.
|
|
|
|
Original file is located at
|
|
https://colab.research.google.com/drive/1VhjxRGwEACSu603yf4vSszy0Ii6hNzex
|
|
|
|
**PROGRAM FIZZBUZZ 1-100**
|
|
|
|
~ *Program FizzBuzz menggunakan c++*
|
|
"""
|
|
|
|
# Commented out IPython magic to ensure Python compatibility.
|
|
# %%bash
|
|
# cat << 'EOF' > fizzbuzz.cpp
|
|
# #include <iostream>
|
|
# using namespace std;
|
|
#
|
|
# int main() {
|
|
# for(int i = 1; i <= 100; i++) {
|
|
# if(i % 3 == 0 && i % 5 == 0) {
|
|
# cout << i << " FizzBuzz" << endl;
|
|
# }
|
|
# else if(i % 3 == 0) {
|
|
# cout << i << " Fizz" << endl;
|
|
# }
|
|
# else if(i % 5 == 0) {
|
|
# cout << i << " Buzz" << endl;
|
|
# }
|
|
# else {
|
|
# cout << i << endl;
|
|
# }
|
|
# }
|
|
# return 0;
|
|
# }
|
|
# EOF
|
|
#
|
|
# g++ fizzbuzz.cpp -o fizzbuzz
|
|
# ./fizzbuzz
|
|
|
|
"""~ *Program FizzBuzz menggunakan Python*"""
|
|
|
|
for i in range(1, 101):
|
|
if i % 3 == 0 and i % 5 == 0:
|
|
print(i, "FizzBuzz")
|
|
elif i % 3 == 0:
|
|
print(i, "Fizz")
|
|
elif i % 5 == 0:
|
|
print(i, "Buzz")
|
|
else:
|
|
print(i) |