0

I need to create a program in which it allows the user to choose the quantity of perfect combinations that they want to see. A combination is perfect when the number is multiple of 3 and 5. For example if I have input 5 the program will need to start from 0 and once it reaches the number that is perfect shows a "perfect" each time it is perfect

I have been trying to use:

combi = (int(input())
count = 0

for i in range(combi):
      if (i % 3 == 0 and i % 5 == 0):
          print("Perfect")

I do not know how to make it count since 0 until we have 5 numbers which are perfect

Paul Rooney
  • 20,879
  • 9
  • 40
  • 61

1 Answers1

0

Use the break statement:

combi = (int(input())
count = 0

for i in range(combi):
      if (i % 3 == 0 and i % 5 == 0):
          print("Perfect")
          count += 1
      if count == 5:
          break
Synthase
  • 5,849
  • 2
  • 12
  • 34