In Python, is there a way to test if a number is divisible by multiple numbers without writing out the modulo operation for each factor?
More specifically, is there
The above answer was:
if all(i % n == 0 for n in range(11, 101)):
print(i)
which, it should be mentioned as clarification, only works with the built-in all function. I use Spyder, which by default uses the all from numpy.core.fromnumeric, and the above answer will not work in that case. Then use the following:
import __builtin__
if __builtin__.all(i % n == 0 for n in range(11, 101)):
print(i)