I'm trying to create a program called "composites" using maple that accepts a user input of n and prints out the first n composite numbers using the isprime function although I have no idea as to how I would go about doing this as I have very little experience with maple. Here is my current code, although it is probably horribly incorrect.
composites := proc (n)
local i, L;
L := [];
for i to n do if isprime(n) then L := [op(L), i] end if end do;
L
end proc
Any help would be appreciated
Many Thanks
You are close. You have to test
isprime(i)and notisprime(n), since it isirather thannwhich is changing.Also, you only want to augment list
Lwheneverisprimereturns false. So you wantnot isprime(i)in the conditional.You could also code it in a more functional manner, eg,