Question: Write a function int *numSequences(std::vector *primes, int num) that takes a vector of primes, an integer of interest, and returns the number of representations for

Write a function int *numSequences(std::vector *primes, int num) that takes a vector of primes, an integer of interest, and returns the number of representations for that given positive integer.

Write a function int *numSequences(std::vector *primes, int num) that takes a vector

#include #include "Primes.h"

std::vector *genPrimes(int M) { std::vector *v = new std::vector(); std::vector *t = new std::vector(M); int i=0; int nextPrime = 2;

for(i=0; i

(*t)[0]=0; (*t)[1]=0;

v->push_back(2);

while (nextPrime push_back(nextPrime); break; } }

delete t; return v; }

int numSequences(std::vector *primes, int num) {

// your code here

// code to quell compiler complaints. Delete it. return num + (*primes)[1]; }

Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive integer have? For example, the integer 53 has two representations: 5 7 + 11 13 17 and 53. The integer 41 has three representations 2+3+5+7+11+13, 11+13+17, and 41. The integer 3 has only one representation, which is 3 . The integer 20 has no such representations. Note that summands must be oonseoutive prime numbers, so neither 713 nor 3 557 is a valid representation for the integer 20 Write a funotion int *numSequences (std::vector *primes, int num) that takes a veotor of primes that you learned to create for the Primes POTD, an integer of interest, and returns the number of representations for that given positive integer

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!