KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am just starting to learn to code in Python. I am trying to write some code to answer this Project Euler Question: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? My program works with the test case of 13195, but when I try to enter 600851475143, I get the error: "OverflowError: range() results has too many items" Does anyone know how I can fix this? Here is my code: class Euler3: "A class to find the largest prime factor of a given number" n = 600851475143 primeFactors = [] for i in range(2,n): if (n%i ==0): primeFactors.append(i) n = n/i i = i -1 #reset i print primeFactors Any help or suggestions would be much appreciated!
Tags (comma-separated)
Save Edits
Cancel