Quick actions

cmd+k|ctrl+k

Navigation

Languages

SmallestMultiple

Snippet info

Language

Python

Visibility

public

Author

chaosrock

Created

2016-09-17T19:52:12Z

Updated

2016-09-17T19:52:12Z

def smallest_multiple(start, end):
    if (start > end):
        return -1
    
    i = 0
    while (True):
        i += 20
    # start incrementing a number until we find the smallest multiple
        for j in range(start, end + 1):
        # for each number, run a for loop to see if it is the smallest multiple
            if i % j > 0:
                break
            if j == end and i % j == 0:
                return i
                
print(smallest_multiple(1,20))
INFO