Cody

Problem 44305. 5 Prime Numbers

Created by goc3 in Cody5:Easy

Your function will be given lower and upper integer bounds. Your task is to return a vector containing the first five prime numbers in that range that contain the number five. But, if you can't find at least five such numbers, the function should give up and return -1.

For example, for n_min = 60 and n_max = 1000, the set of prime numbers is:

 p = [61,67,71,73,79, ... 149,151,157,163, ... 241,251,257,263, ... 349,353,359,367, ... 983,991,997]

This set contains at least five numbers that contain a five; the first five are:

 p5 = [151,157,251,257,353]

which is the set that your function should return in this case. If, however, n_max were set at 300, five such numbers do not exist and the function should then give up (return -1).

Solution Stats

41.66% Correct | 58.34% Incorrect
Last solution submitted on Jul 31, 2018

Problem Comments

Solution Comments

Recent Solvers301

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!