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

Solution 190874

Submitted on 14 Jan 2013 by Richard Zapor

Correct

32Size
Leading solution size is 6.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
filetext = fileread('prime_time.m')
assert(isempty(strfind(filetext, 'fopen')))
filetext =
function b=prime_time(x)
 while 1
  a=clock;
  b=floor(polyval(a(5:6),60));
  if isprime(b),return;end
 end
end
%This code written by profile_id 2789428
2
Pass
 
%%
x=123
y = prime_time(x)
a=clock
b=floor(polyval(a(5:6),60))
if isprime(b)
y_correct= y
else
y_correct = NaN;
end
assert(isequal(y,y_correct),sprintf('%s%g%s','Time is ',datestr(now,13),', or ',b,' seconds after the hour.'))
x =
   123
y =
        3083
a =
   1.0e+03 *
    2.0130    0.0010    0.0140    0.0200    0.0510    0.0230
b =
        3083
y_correct =
        3083