Results 1 to 4 of 4

Math Help - matlab code helpppp :(

  1. #1
    Newbie
    Joined
    Oct 2009
    Posts
    11

    matlab code helpppp :(

    helpp!! i need a MATLAB CODE!


    2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

    What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?


    i need the matlab code for this it is so confusing i got other codes but they do not seem to be working
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by savni98 View Post
    helpp!! i need a MATLAB CODE!


    2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

    What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?


    i need the matlab code for this it is so confusing i got other codes but they do not seem to be working
    First decide what algorithm you are going to employ, then post it here and explain what it is with the algorithm you are having trouble turning into code.

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Oct 2009
    Posts
    11
    i got some of the code i think i dont know what to do ??


    for i = 20:2:1000000000
    t = 0;
    for j = 2:20
    t += 1
    end
    end
    if t == 19


    without the code it goes



    20=2*2*5
    19
    18=2*3*3
    17
    16=2*2*2*2
    15=3*5
    14=2*7
    13
    12=2*6
    11
    10=2*5
    9=3*3
    8=2*2*2
    7
    6=2*3
    5
    4=2*2
    3
    2
    1


    2*2*2*2*3*3*5*7*11*13*17*19=232,792,56
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by savni98 View Post
    i got some of the code i think i dont know what to do ??


    for i = 20:2:1000000000
    t = 0;
    for j = 2:20
    t += 1
    end
    end
    if t == 19


    without the code it goes



    20=2*2*5
    19
    18=2*3*3
    17
    16=2*2*2*2
    15=3*5
    14=2*7
    13
    12=2*6
    11
    10=2*5
    9=3*3
    8=2*2*2
    7
    6=2*3
    5
    4=2*2
    3
    2
    1


    2*2*2*2*3*3*5*7*11*13*17*19=232,792,56
    Start with p=20, then loop from n= 19 down to 1 with update p=lcm(n,p)

    so the core code would look something like:

    Code:
    p=20
    n=19:-1:1
       p=lcm(p,n);
    end
    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab code
    Posted in the Math Software Forum
    Replies: 2
    Last Post: April 4th 2011, 02:18 AM
  2. MATLAB code
    Posted in the Calculus Forum
    Replies: 0
    Last Post: November 5th 2009, 05:44 AM
  3. matlab code sequences
    Posted in the Math Software Forum
    Replies: 1
    Last Post: October 19th 2009, 11:55 PM
  4. Need MAtlab code
    Posted in the Math Software Forum
    Replies: 1
    Last Post: April 26th 2009, 09:57 PM
  5. Need to do this by matlab code emengercy please help
    Posted in the Advanced Applied Math Forum
    Replies: 0
    Last Post: April 7th 2008, 06:30 PM

Search Tags


/mathhelpforum @mathhelpforum