Largest Prime Factor

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 3583 Views - Last Post: 12 September 2010 - 05:01 PM Rate Topic: -----

#16 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Largest Prime Factor

Posted 12 September 2010 - 04:57 PM

I would use the Sieve of Eratosthenes to sieve primes from 2-sqrt(n). As the Sieve runs in O(n^(3/2)) time, and it is using sqrt(n) for it's n, that would be O(n^(3/4)) based on your original number. And if none of the primes sieved are factors of n, then n is the largest prime.
Was This Post Helpful? 0
  • +
  • -

#17 Brewer   User is offline

  • Awesome
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,044
  • Joined: 14-June 10

Re: Largest Prime Factor

Posted 12 September 2010 - 04:59 PM

Is creating an algorithm for the Sieve of Eratosthenes difficult to create?
Was This Post Helpful? 0
  • +
  • -

#18 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Largest Prime Factor

Posted 12 September 2010 - 05:01 PM

Check out Wikipedia as well as the snippets sections. There are tons of examples. It's basically nested for loops and a List.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2