How do I devide natural numbers by values in a tuple? | Sololearn: Learn to code for FREE!
0

How do I devide natural numbers by values in a tuple?

I have this assignment and am not sure how to proceed: 'Write a program that creates a list of natural numbers from 1 to 100, divisible by values contained in the tuple, e.g: (2,3,7). Print the list on the screen.' Could someone help me? I got only to the point of finding the natural numbers, but dividing them through a tuple is a problem. Do I make a list of the primes and iterate sort of through that? Or do I iterate through the tuple?

16th Mar 2022, 5:19 PM
Weronika Pucek
3 ответов
+ 3
Weronika Pucek , #we need to use 2 nested for loops: we need a tuple of divisors use the outer loop to iterate through a range from 1 upto 100 including use the inner loop to iterate through the tuple check if division of the number % divisor results to 0 if yes: print that number
16th Mar 2022, 7:51 PM
Lothar
+ 2
Using map or filter built-in functions is useful
16th Mar 2022, 6:45 PM