michael_flaherty_ps5_primeNumberChecker

.py

School

Stockton University *

*We aren’t endorsed by this school

Course

2210

Subject

Computer Science

Date

Oct 30, 2023

Type

py

Pages

1

Uploaded by JudgeRoseWalrus50

Report
def is_prime(number): if number < 2: return False for i in range(2, int(number ** 0.5) + 1): if number % i == 0: return False return True def find_factors(number): factors = [] for i in range(1, number + 1): if number % i == 0: factors.append(i) return factors def main(): print("Prime Number Checker") while True: try: user_input = int(input("Please enter an integer between 1 and 5000: ")) if 1 <= user_input <= 5000: if is_prime(user_input): print(f"{user_input} is a prime number.") else: print(f"{user_input} is NOT a prime number.") factors = find_factors(user_input) print(f"It has {len(factors)} factors: {', '.join(map(str, factors))}") else: print("Error: Please enter an integer between 1 and 5000.") except ValueError: print("Error: Please enter a valid integer.") try_again = input("Try again? (y/n): ").lower() if try_again != 'y': break print("Bye!") if __name__ == "__main__": main()
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: Rooneyia is an Eocene primate fossil. This ____ found in Texas is distinct from other North American…
Q: which of the following metal ions would form the strongest M-EDTA bonds? Group of answer choices…
Q: v =
Q: A data set about speed dating includes​ "like" ratings of male dates made by the female dates. The…
Q: Which feature is embedded to find content throughout a website?
Q: The balanced chemical equation for the reaction between perchloric acid (HCIO4) and tetraphosphorus…
Q: 10) (Section 9.7) Use vectors to find the largest interior angle of the triangle with the (1, 2),…
Q: In the following compounds, consider hydrogens in the specified positions: На Нь H₁ Н, Нc He OH
Q: Assume that when adults with smartphones are randomly​ selected, 44% use them in meetings or…
Q: What is the Kb for the conjugate base of an unknown acid with a Ka of (8.4x10^-3) What is the pH of…
Q: Follow the seven step strategy to graph the following rational function. f(x) = x + 2 x + 3x - 10 To…
Q: When studying radioactive​ material, a nuclear engineer found that over 365​ days, 1,000,000…
Q: of the Wing are oxidation-reduction reactions, and if it is, Identify the oxidizing agent, the…
Q: what would the answer be with two decimal places?
Q: What will be the output of the following code fragment? int func(int x) {      int a = 10;      x =…
Q: Graphical Analysis: If the velocity versus time graph of an object is a horizontal line, the object…
Q: Need help with these program/s for each of the following problem statements.  - comment statements…
Q: Free Fall: A 10-kg rock and a 20-kg rock are thrown upward with the same initial speed vo and…
Q: Find the indicated IQ score. The graph to the right depicts IQ scores of​ adults, and those scores…
Q: Solve the following equation for on the interval [0, 360°). Select all correct answers. Select all…
Q: { if(used capacity) { resize((1.5*capacity) + 1); } if(current index >= used) current_index = 0; { }
Q: What mass of compound is present in 4.60 mol of each of the following compounds? a. Mass= b.…