Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please fix my code: num _ primes = int ( input ( How many primes: ) ) num _ factors = 0 prime

Please fix my code: num_primes = int(input("How many primes: "))
num_factors =0
prime_count =0
prime_candidate =2
while prime_count < num_primes:
for potential_factor in range(2, prime_candidate):
if prime_candidate%potential_factor ==0:
num_factors = num_factors +1
if num_factors ==0:
print(str(potential_factor))
prime_candidate = prime_candidate +1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions