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
std::vector
return v; }
primes.h
#ifndef _PRIMES_H #define _PRIMES_H
#include
std::vector
#endif
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
