Home > Back-end >  How to print 100 values which are divisible by 3 and 5?
How to print 100 values which are divisible by 3 and 5?

Time:02-17

lower = int(input("Enter lower 
 range limit:"))
upper = int(input("Enter upper b 
range limit:"))
Count = 0
for i in range(lower, upper 1):
    if((i%3==0) & (i%5==0)):
    Count  = 1
    print(count)

I want to print 100 values which are divisible by 3 and 5 ,but in count only 7 is showing , can anyone suggest i will be appreciated!

CodePudding user response:

Use this

num = int(input("How many Numbers you want :"))

i=0
Count = 0
while(Count != num):
    if((i%3==0) and (i%5==0)):
        Count  = 1
        print(i)
    i = i   1

print("Count is :",Count)

CodePudding user response:

Do it with while loop:

count = 0
i=0
upper=100
while count<upper:
    if((i%3==0) and (i%5==0)):
    count  = 1
   i =0
    print(count)
  • Related