Third Project Euler problem - Solved! Second problem
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? Sunday, November 21, 2010
Parent Teacher Conference Jokes
To achieve this response was sufficient to read the code
function factor () in Matlab, Matlab fortunately is not as exclusive as to study their code and even modify it, maybe (most secure) has not "permission" to do such a thing, but doing a little reading of the code of this function of Matlab could not be used directly because it only solves the decomposition of numbers up to 2 ^ 32, I wrote this little script which I found solution to Project Euler Problem 3.
n = input ('Enter the value to decompose into prime factors')
if n \u0026lt;0 error ('n must be a non-negative integer') end primes p = (sqrt (n )),% find many prime numbers as the square root of u = find (rem (n, p) == 0);% compare the contents of the vector p with the divisors of n and selects those with remaining 0 disp (p (d))% show the prime factors of n One way to verify that this was correct was to use the fundamental theorem of arithmetic TFA: "Every integer n> 1, or is prime, or can be factored as a product of primes. This product is unique except for the order of the factors. "
This still learning and continuing progress in the Project Euler list.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment