Sunday, December 26, 2010

Upper Lips Of Dog Swells. Causes?

Two hours of processing for a number

The problem or Collatz Conjecture, a problem proposed by the mathematician Lothar Collatz in 1937 and has not yet been shown, generates a series of whole numbers is always presumed that ends in one, approach says that if n is even the new term is n / 2, where 3n +1 is odd, so for example with the entire first 13, the series will

13 to 40 - 20 - 10 - 5 to 16 - 8 - 4 - 2 -1

The problem proposed in the draft to find the entire Euler indicates less than a million producing the longest Collatz chain, this implies in the script that I developed to calculate Collatz chain with all the integers less than 1000000 and determine each of those million channels, few elements have, so after just over two hours I dropped the response process, the longest string that is generated with an integer less than a million contains 525 items, the question concerned at what the original whole that generates that string, the answer can be found running the following script in matlab ;-)


clc;
clear all;
i = 2, j = 1;
k = input ('Enter the initial maximum value k =');
while k ~ = 1
n = k;
 c(1)=n;
    while n~=1
        if rem(n,2)~=0
            n=3*n+1;
        elseif rem(n,2)==0
            n=n/2;
        end
        c(i)=n; % Vector containing the full chain including the initial term if

n ~ = 1 i = i +1;% Indisa the terms of the chain

elseif n == 1 i = 2;
end end

m1 (j, 1) = c (1);% Vector of initial values \u200b\u200bof the chain
m2 (j, 1) = length (c);% Vector of the number of terms each string
M = [m1 m2];
clear c;
j = j +1, k = k-
1;

end disp (m1 (find (m2 == max (m2)), 1));


PDTA: This algorithm makes it equivalent to a brute force attack because it determines each of the chains Collatz The most practical way to resolve reduce running time Collatz function built into Matlab .

esDebian

0 comments:

Post a Comment