How to work dis
IM trying to make a project that prints out the first 25 prime numbers but it doesn't work
Answered by MoltasDev (10) [earned 5 cycles]
What is your technique for calculating primes? I wrote a quick program in Python3 to calculate this - you can use a similar technique.
# Python3 def prime_check(n): # Creates list with factors and measures length factor_len = len([i for i in range(1,n+1) if n % i == 0]) # Number with 2 factors is prime if factor_len == 2: return "Prime" else: pass prime_list =  number = 2 while len(prime_list) < 25: prime = prime_check(number) if prime == "Prime": # Adding number to list if prime prime_list.append(number) else: pass number += 1 print(prime_list)