How can I use the isprime function in C?

January 16 2012 by mattcanderson1 15
false
Maple 13

1


HI,

I want to make a program that will list the twin primes.  Is it possible to implement the isprime function in C?  I want to be able to run this program on a computer that doesn't have Maple installed.  Here is my code -

twinprimes := proc (maxnum)
local a;
description "output the twin primes less than maxnum";
printf("%12d", 3);
for a from 6 by 6 to maxnum do
if `and`(isprime(a-1) = true, isprime(a+1) = true)
then printf("%12d", a-1) end if
end do
end proc:
twinprimes(100);           

with(CodeGeneration);
C(twinprimes, resultname = "w");
Warning, the function names {isprime} are not recognized in the target language

 

 
Loading Comments & Answers

You must be logged into your MaplePrimes account in order to post a comment. If you don't have an account, you can create an account here.

     

Forgot Your Password? Create an Account