You are viewing a single comment's thread. Return to all comments →
def is_prime(num): if num < 2: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def first_n_primes(n): primes = [] num = 2 while len(primes) < n: if is_prime(num): primes.append(num) num += 1 return primes def waiter(number, q): primes = first_n_primes(q) answers = [] arr = number for p in primes: B=[] A =[] for e in arr: if e % p == 0: B.append(e) else: A.append(e) answers+=B arr = A[::-1] answers +=A return answers
Seems like cookies are disabled on this browser, please enable them to open this website
Waiter
You are viewing a single comment's thread. Return to all comments →