Determine the smallest positive integer whose first 6 multiples (including itself) contain the digit 2.
(In reply to
re: Brute force solution by Charlie)
Hi Charlie,
The extent of the While, For, and If statements are all determined by the indentation of the code (is it not appearing indented to you? It looks ok on my screen but maybe it's formatted differently in different browsers or something?)
If it helps clarify I'll add some comments (indicated by the # sign) to indicate where things stop:
num = 2
ans = 0
WHILE ans == 0:
ans = num
FOR m in range(1,7):
mult = num * m
IF '2' not in list(str(mult)):
ans = 0
break
# END IF
# END FOR LOOP
num += 1
# END WHILE LOOP
print ans, ans*2, ans*3, ans*4, ans*5, ans*6
|
Posted by tomarken
on 2014-02-28 13:33:13 |