Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def isPrime(number):
  prime = True
  if number < 2:
    prime = False
  else:
    for factor in range(2,int(number**0.5)+1):
      if number % factor == 0:
        prime = False
  return prime

def ask(question):
  answer = -1
  while answer < 0:
    try:
      answer = int(input(question))
      if answer < 1:
        print("Positive numbers only, please.")
        answer = -1
    except:
      answer = -1
  return answer
  
numbers = []
max = ask("How many numbers would you like in the sequence? ")
a = ask("First multiple to look for? ")
b = ask("Second multiple to look for? ")
for n in range(1, max+1):
  output = ""
  if n % a == 0:
    output = "Fizz"
  if n % b == 0:
    output += "Buzz"
  if isPrime(n):
    output = "OOPS!"
  if output == "":
    output = n
  print(output)