Ziaahmed812

25 Reputation

One Badge

3 years, 316 days

MaplePrimes Activity


These are questions asked by Ziaahmed812

I have made a procedure named Eratosthenes that will return a sequence of all the primes less than some given number N which must be a positive integer. However, I couldn't figure out the error but still, the code is not working either. Can anyone please go through my code to let me know if I have a mistake? Thanks.

Eratosthenes := proc (N::posint) local L, primeslist, n, k; description "Calculate all primes less than or equal to N"; L := Array(2 .. N, proc (i) options operator, arrow; true end proc); for n from 2 to trunc(sqrt(N)) do if L__n = true then for k from n while k*n <= N do `L__k*n` := false end do end if end do; primeslist := NULL; for n from 2 to N do if L__n = true then primeslist := primeslist, n end if end do; primeslist end proc:

Warning, ``L__k*n`` is implicitly declared local to procedure `Eratosthenes`

 

``NULL


 

Download issue.mwissue.mw

I have been trying to solve the following question using Maple for quite some time but couldn't do it. Any guide will be highly appreciated. 

P.S: I have just started learning it by myself in the last few days. I have been following An Introduction to Modern Mathematical Computing: With Maple. If you could suggest a more useful text, that would be helpful.

Please find the question below.

Page 1 of 1