Cody

# Problem 1319. Leap years on other planets

Solution 721315

Submitted on 25 Aug 2015 by Binbin Qi
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

### Test Suite

Test Status Code Input and Output
1   Pass
N={'Mercury','Venus','Earth','Mars','Jupiter',... 'Saturn','Uranus','Neptune','Pluto'}; P=[0.5000 1.9246 365.2425 668.5950 10471.0182 ... 24204.8198 42582.9327 89087.3743 14183.7398]; for i=1:9 p=P(i); m=leapsequence(p); n=numel(m); r=dot(1./m,(-1).^(0:n-1)); disp([N{i} ' p=' num2str(p,'%0.6f') ... ' r=' num2str(r,'%0.6f') ' m=' mat2str(m)]) assert(abs(floor(p)+r-p)<=0.00005); assert(all(m>0)) assert(all(mod(m,1)==0)) assert(all(mod([m 0],[1 m])==0)) end

Mercury p=0.500000 r=0.500000 m=2 Venus p=1.924600 r=0.924615 m=[1 13 650] Earth p=365.242500 r=0.242494 m=[4 132 14256] Mars p=668.595000 r=0.595000 m=[1 2 10 200] Jupiter p=10471.018200 r=0.018205 m=[54 3186] Saturn p=24204.819800 r=0.819800 m=[1 5 50 5000] Uranus p=42582.932700 r=0.932703 m=[1 14 238 14280] Neptune p=89087.374300 r=0.374294 m=[2 6 24 1416] Pluto p=14183.739800 r=0.739796 m=[1 3 12 96 4704]