简体   繁体   中英

Fill in the blanks to make the print_prime_factors function print all the prime factors of a number

Fill in the blanks to make the print_prime_factors function print all the prime factors of a number. A prime factor is a number that is prime and divides another without a remainder.

 def print_prime_factors(number): # Start with two, which is the first prime factor = ___ # Keep going until the factor is larger than the number while factor <= number: # Check if factor is a divisor of number if number % factor == ___: # If it is, print it and divide the original number print(factor) number = number / factor else: # If it's not, increment the factor by one ___ return "Done" print_prime_factors(100) # Should print 2,2,5,5

Fill in the blanks to make the print_prime_factors function print all the prime factors of a number. A prime factor is a number that is prime and divides another without a remainder.

 def print_prime_factors(number): # Start with two, which is the first prime factor = ___ # Keep going until the factor is larger than the number while factor <= number: # Check if factor is a divisor of number if number % factor == ___: # If it is, print it and divide the original number print(factor) number = number / factor else: # If it's not, increment the factor by one ___ return "Done" print_prime_factors(100) # Should print 2,2,5,5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM