Thursday, December 2, 2010

18 Year Old Nephew Birthday Wishes

Other problems already solved - Project Euler Palindromes

After finding the solution to the problem of palindromes, (which he think) the fifth was also very interesting problem to solve but comfortable, the most interesting of this problem is so such as palindromes, the generated script allows you to test the processing power of the machine, the fifth problem, my laptop took 28 minutes to throw a response as my desktop only took 8 minutes to get to devote only one of its four cores.

The problem is to find the smallest positive number that is divisible by all the natural range of 1 to 20, the answer is 232792560.

The script was generated to achieve the following

% Find the smallest number that is divisible by all the series and to n

% n = input ('Enter the number of splitters');% initial dividend
d = (1: n) % Vector of divisors
r = rem (n, d);% of the remaining vector
while any (r) == 1% if any of the remaining non-zero
n = n +1 ;% new dividing
r = rem (n, d);

end if r == 0% if all remnants are zero
disp (n);
disp (r);

end


After this problem appeared one that is very easy to fix. Find the difference between the sum of the squares of the first 100 natural and the square of the sum of the first 100 natural. 25164150 Response. For this problem is not necessary to generate any script, simply create a natural vector of one (1) to twenty (20) and use the SUM function.

N = (1:20)% generates a natural vector of 1 to 20
d = sum (N ^ 2) - (sum (N)) ^ 2


and that's it. The next problem is also very simple to solve. Ask to meet the prime number 10001, that by using the primes is in a couple of seconds.

I still addressing the problems of the Euler Project, I pair the eighth problem.
esDebian

0 comments:

Post a Comment