Hi everyone, Can you help me
조회 수: 1 (최근 30일)
이전 댓글 표시
If we list all the natural numbers up to 15 that are multiples of 3 or 5, we get 3, 5, 6, 9, 10, 12 and 15. The sum of these multiples is 60. Write a function called sum3and5muls that returns the sum of all the unique multiples of 3 or 5 up to n where n is a positive integer and the only input argument of the function. (Credit: Project Euler) I do anything the above question. I dont know loop yet. Can you give some hints please?
댓글 수: 1
답변 (4개)
Jos (10584)
2017년 10월 30일
I give you a suggestion
tf = false(1,n)
tf(x:x:n) = true
w = find(tf)
sum(w)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Software Development Tools에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!