Skip to content
Advertisement

Variable is not divisible by an unspecific set of Numbers

I just started to code and try to build my first function in Python/NumPy. My first goal was to get a list for all multiplies of 31 which are not divisible by numbers 1>31 and I figured it out

Here is the code:

JavaScript

The next step is to make the function more flexible, but easy ideas like this just don’t work, obviously:

JavaScript

Advertisement

Answer

The answer will be something like

JavaScript

where [x for x in A[0] if ....] is a list comprehension meaning we take every element in array A[0] and add it to the new array C if can_multiply func returns True

Advertisement