| 
October 18th, 2009, 10:55 PM
| | Newbie | | Join Date: Oct 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
| | 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 | 
October 19th, 2009, 12:16 AM
|  | Grand Panjandrum | | Join Date: Nov 2005 Location: South of England
Posts: 11,375
Country: Thanks: 667
Thanked 3,618 Times in 2,915 Posts
| | Quote:
Originally Posted by savni98 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
__________________ Truth does not change because it is, or is not, believed by a majority of the people.
Giordano Bruno | 
October 19th, 2009, 02:28 PM
| | Newbie | | Join Date: Oct 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
| | 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 | 
October 20th, 2009, 02:06 AM
|  | Grand Panjandrum | | Join Date: Nov 2005 Location: South of England
Posts: 11,375
Country: Thanks: 667
Thanked 3,618 Times in 2,915 Posts
| | Quote:
Originally Posted by savni98 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
__________________ Truth does not change because it is, or is not, believed by a majority of the people.
Giordano Bruno | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -7. The time now is 07:21 AM. | | |
 | |  |