Tuesday, 17 September 2019

Python program to print all the numbersdivisible by 3 and 5 for a given number

# Python program to print all the numbers
# divisible by 3 and 5 for a given number
  
# Result function with N
def result(N):
      
    # iterate from 0 to N
    for num in range(N):           
            # Short-circuit operator is used 
            if num % 3 == 0 and num % 5 == 0:
                print(str(num) + " ", end = "")
                  
            
      
#main program
N = 100
  
# Calling function
result(N)

No comments:

Post a Comment