Insights Blog
-- Browse All Articles --
Physics Articles
Physics Tutorials
Physics Guides
Physics FAQ
Math Articles
Math Tutorials
Math Guides
Math FAQ
Education Articles
Education Guides
Bio/Chem Articles
Technology Guides
Computer Science Tutorials
Forums
Intro Physics Homework Help
Advanced Physics Homework Help
Precalculus Homework Help
Calculus Homework Help
Bio/Chem Homework Help
Engineering Homework Help
Trending
Featured Threads
Log in
Register
What's new
Search
Search
Search titles only
By:
Intro Physics Homework Help
Advanced Physics Homework Help
Precalculus Homework Help
Calculus Homework Help
Bio/Chem Homework Help
Engineering Homework Help
Menu
Log in
Register
Navigation
More options
Contact us
Close Menu
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Forums
Homework Help
Engineering and Comp Sci Homework Help
Project Euler Question 58 -- ratio of primes along both diagonals of a spiral....
Reply to thread
Message
[QUOTE="Arman777, post: 6015740, member: 579807"] whats j or primes in here ? At first my code was something like [code=Python]def prime(N): if N == 1: return False y = int(N**0.5) for i in range(2,y+1): if N%i == 0: return False return True def finder(N): L = len(N) count = 0 for i in N: if prime(i) == True: count += 1 return countfor J in range(2,30000): D1 = [(2*n+1)**2 for n in range(1,J)] D2 = [4*n**2+1 for n in range(1,J)] D3 = [4*n**2+2*n+1 for n in range(1,J)] D4 = [(4*n**2)-(2*n)+1 for n in range(1,J)] f = finder(D1) + finder(D2) + finder(D3) + finder(D4) d = f/((J-1)*4+1) if d < 0.10: print(d) print((J-1)*2+1)[/code] or this was my idea but then it just don't work fast enough I guess you are checking for each number rather then putting them into the array and check them one by one. Definitly much faster algorithm [/QUOTE]
Insert quotes…
Post reply
Forums
Homework Help
Engineering and Comp Sci Homework Help
Project Euler Question 58 -- ratio of primes along both diagonals of a spiral....
Back
Top