Math Help Forum

Math Help Forum Feed Site Feed

Go Back   Math Help Forum > Math Resources > Mathematics Software Discussion
Reply
 
Thread Tools Display Modes
  #1  
Old October 18th, 2009, 10:55 PM
Newbie
 
Join Date: Oct 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
savni98 is on a distinguished road
Default 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
Reply With Quote
Advertisement
 
  #2  
Old October 19th, 2009, 12:16 AM
CaptainBlack's Avatar
Grand Panjandrum
 
Join Date: Nov 2005
Location: South of England
Posts: 11,375
Country:
Thanks: 667
Thanked 3,618 Times in 2,915 Posts
CaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond repute
Default

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
__________________
Truth does not change because it is, or is not, believed by a majority of the people.

Giordano Bruno
Reply With Quote
  #3  
Old October 19th, 2009, 02:28 PM
Newbie
 
Join Date: Oct 2009
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
savni98 is on a distinguished road
Default

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
Reply With Quote
  #4  
Old October 20th, 2009, 02:06 AM
CaptainBlack's Avatar
Grand Panjandrum
 
Join Date: Nov 2005
Location: South of England
Posts: 11,375
Country:
Thanks: 667
Thanked 3,618 Times in 2,915 Posts
CaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond reputeCaptainBlack has a reputation beyond repute
Default

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
__________________
Truth does not change because it is, or is not, believed by a majority of the people.

Giordano Bruno
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -7. The time now is 07:21 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
©2005 - 2009 Math Help Forum


Math Help Forum is a community of maths forums with an emphasis on maths help in all levels of mathematics.
Register to post your math questions or just hang out and try some of our math games or visit the arcade.