Cody

Problem 1688. Prime Sequences: AP-k Minimum Final Value

Solution 1279022

Submitted on 30 Sep 2017 by yurenchu
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
n=4; p=3; [a,b]=APk_min_end(p,n); toc assert(isequal(a+b*prod(primes(p))*n,29))

b = 1 a = 5 Elapsed time is 0.288861 seconds.

2   Pass
n=5; p=5; [a,b]=APk_min_end(p,n); toc assert(isequal(a+b*prod(primes(p))*n,157))

b = 1 a = 7 Elapsed time is 0.452666 seconds.

3   Pass
n=6; k=5; [a,b]=APk_min_end(k,n); toc assert(isequal(a+b*prod(primes(k))*n,907))

b = 5 a = 7 Elapsed time is 0.624406 seconds.

4   Pass
n=7; k=7; [a,b]=APk_min_end(k,n); toc assert(isequal(a+b*prod(primes(k))*n,1669))

b = 1 a = 199 Elapsed time is 0.805286 seconds.

5   Pass
n=8; k=7; [a,b]=APk_min_end(k,n); toc assert(isequal(a+b*prod(primes(k))*n,1879))

b = 1 a = 199 Elapsed time is 0.974903 seconds.

6   Pass
n=9; k=7; [a,b]=APk_min_end(k,n); toc assert(isequal(a+b*prod(primes(k))*n,2089))

b = 1 a = 199 Elapsed time is 1.129425 seconds.

7   Pass
n=10; k=11; [a,b]=APk_min_end(k,n); toc assert(isequal(a+b*prod(primes(k))*n,249037))

b = 6 a = 110437 Elapsed time is 12.097199 seconds.

8   Pass
n=11; k=11; [a,b]=APk_min_end(k,n); toc assert(isequal(a+b*prod(primes(k))*n,262897))

b = 6 a = 110437 Elapsed time is 24.629639 seconds.

9   Pass
n=12; k=13; [a,b]=APk_min_end(k,n); toc assert(isequal(a+b*prod(primes(k))*n,725663))

b = 2 a = 4943 Elapsed time is 43.266172 seconds.

Suggested Problems

More from this Author241

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!