Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Maple a) Write a procedure, primesum, whose input is a positive integer n and whose output is the sum of all primes p such that

Maple a) Write a procedure, primesum, whose input is a positive integer n and whose output is the sum of all primes p such that p <= n. You may use the built-in procedure isprime. Test the procedure for n= 2, 4, 10, and 1000.

primesum:=proc(n) local SUM, k; SUM:=0; for k from 1 to n do if isprime(k)=true then SUM:=SUM + k; end if; end do; end proc: primesum(12);

I did this but no result comes out when the number input is not prime. How do I fix this? I have the same problem with the next one.

b) Write a procedure, primeset, whose input is a positive integer n and whose output is the set of all primes p such that p <= n. You may use the built-in procedure isprime. Test the procedure for n = 2, 4, 10, and 1000.b) Write a procedure, primeset, whose input is a positive integer n and whose output is the set of all primes p such that p <= n. You may use the built-in procedure isprime. Test the procedure for n = 2, 4, 10, and 1000.

primeset:=proc(n) local SUM, S,k; S:={}; for k from 1 to n do if isprime(n)=true then S:=S union {k}; end if; end do; end proc: primeset(5);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

Explain the different types of marketing strategies.

Answered: 1 week ago

Question

Explain product positioning.

Answered: 1 week ago

Question

Explain Industrial market segment.

Answered: 1 week ago