- #1
miniradman
- 196
- 0
Homework Statement
Project Euler Problem 1.
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Hello, there
I do understand what a multiple is, and how to sum and bunch of numbers... but I have no idea why my algorithm is not delivering the correct result.
When I multiply the array [1:333] by 3, shouldn't I get all the multiples of 3 below 1000? (3, 6, 9... etc), and the same goes for the [1:199] by 5 right? This is a really simple problem, but I don't see where I'm going wrong here
2. The attempt at a solution
clc
clear
x3 = [1:333]*3
x5 = [1:199]*5
all_multi_array = [x3,x5]
sum(all_multi_array)