starlight

60 Reputation

2 Badges

16 years, 25 days

MaplePrimes Activity


These are questions asked by starlight

I've been trying to solve Project Euler's first problem: 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. I've come up with: natural:=proc(n); local i,s; s:=0; for i from 1 to n do if irem(i,3)=0 or irem(i,5)=0 then s:=s+i fi od; return s; end; but I also get the error message: "Error, unexpected `local` declaration in procedure body" Could you please tell me where I've gone wrong? Thanks in advance

Hi!

My teacher gave us an assignment in which he asked us to write a function "factorielle" (which calculates factorials) using recursion.

Having written the function in Maple 12 according to previous instructions that had been given to us:

> factorielle:=n->if n=0 then 1 else n*factorielle(n-1) fi;

Page 1 of 1