Cody

# Problem 1319. Leap years on other planets

Solution 714267

Submitted on 13 Aug 2015 by Vishal Sharma
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.924600 m=[1 13 650 65000] Earth p=365.242500 r=0.242500 m=[4 132 13068 1306800] Mars p=668.595000 r=0.595000 m=[1 2 8 32 768 19200 36650286009600] Jupiter p=10471.018200 r=0.018200 m=[54 3132 1302912] Saturn p=24204.819800 r=0.819801 m=[1 5 45 405 21060] Uranus p=42582.932700 r=0.932700 m=[1 14 238 13566 1641486] Neptune p=89087.374300 r=0.374300 m=[2 6 18 54 216 1296 12960 168480] Pluto p=14183.739800 r=0.739800 m=[1 3 12 96 4608 2875392]