Stuart’s MATLAB Videos

Watch and Learn

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the Original version of the page.

Highlighting solutions to Project Euler problems 001-005 3

Posted by Doug Hull,

I’ve been excited by the great response to the Project Euler problems that I’ve posted on Cody. This video takes a look at my favorite submission for each of the first five problems. Take a look at how other people have solved these problems, you might see some MATLAB techniques that are new to you.

3 CommentsOldest to Newest

Alex replied on : 1 of 3
Hi Doug, Thanks for the ideas. I like how Problem 1 was solved, but I think it should be modified slightly as follows: function y = euler001(x) y = sum(union(3:3:x,5:5:x)) end Otherwise, I get y = 4+7+10... instead of y = 3+5+6+... I may have overlooked something, but thought I'd point this out just in case. Thanks!
Ahmed Abdullah replied on : 2 of 3
hi Alex, No the code for the first problem is okay union(1:3:10,1:5:10)= 1 4 6 7 10; and union(1:3:10,1:5:10)-1 = 0 3 5 6 9; so sum(union(1:3:10,1:5:10)-1)=0+3+5+6+9 =23