online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
def add_primes(minNum, maxNum, prev_primes): '''добавляем простые числа и последние вычеркнутые числа''' nums = list(range(minNum, maxNum+1)) for prime, last_removed in prev_primes.items(): if last_removed < minNum : to_remove = range(last_removed + prime, maxNum+1, prime) else : to_remove = range(last_removed, maxNum+1, prime) for num in to_remove : nums[num - minNum] = 0 prev_primes[prime] = to_remove[-1] # ищем новые простые for num in nums : # если равен нулю, то число вычеркнуто if num != 0: next_prime = num to_remove = range(next_prime * 2, maxNum+1, next_prime) for num1 in to_remove: nums[num1 - minNum] = 0 if len(to_remove) > 0: prev_primes[next_prime] = to_remove[-1] else : prev_primes[next_prime] = 2 * next_prime #return new_prev_primes def get_n_prime(n): "Находит первые n простых чисел" minNum = 2 maxNum = 2*n prev_primes = {} while len(prev_primes) < n: add_primes(minNum, maxNum, prev_primes) minNum = maxNum + 1 maxNum *= 2 return list(prev_primes.keys()) ''' # для проверки, все ли найденные числа простые def is_prime(s): "Проверяет число простое или нет" result = s % 2 or s <= 2 for i in range(3, int(s**0.5) + 1, 2): result = result and s % i return result ''' a = get_n_prime(100) a = a[:100] print(a) ''' # пытаемся найти составные числа compounds = [] for i in a: if not is_prime(i): compounds.append(i) print(compounds) '''

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue