Question: Write a function vector *genPrimes(int M) that returns a pointer to a vector of prime numbers from 2 to M. There are several algorithms to

Write a function vector *genPrimes(int M) that returns a pointer to a vector of prime numbers from 2 to M. There are several algorithms to do this, but the Sieve of Eranthoses is the most common one.

code:

primes.cpp

#include #include "Primes.h"

std::vector *genPrimes(int M) { std::vector *v = new std::vector(); // your code here

return v; }

primes.h

#ifndef _PRIMES_H #define _PRIMES_H

#include

std::vector * genPrimes(int M);

#endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!