Problem 3 - projecteuler.net The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Solve using MATLAB? Solution: To solve this problem we will be using two loops namely for loop and the while loop . We will also use the rem( ) function . This program takes a very little time to generate the solution. The program is as follows: Find the explanation below the program Program function prime_factor(n) %this function will find the largest prime factor of a given number for i = 2 : 1000000 while rem(n,i) == 0 n = n/i; fprintf( 'Yay, %d is a factor, now we should test %d \n' ,i, n); if n == 1 || n == i fprintf( '%d\n' ,i); break ; end end end Explanation: First of all the function takes the number as argument. Now a for loop is generated in the range of values 2 to 1000000 (why have I used numbers only till...
With Radius of Circle, people can learn to program and have hands-on tutorials with python and Matlab. ProjectEuler problems solutions are also available to have a better solution and improve the knowledge of people. A lot of algorithms which form the basic programming are also available. I hope the internet community will make use of this blog.