clc
for first=[4:12 2022]
s2=sym(0);
kf=sym(1);
for k=sym(1):sym(first)
kf=kf*(k+1);
s2=s2+k/kf;
end
% s2
s3=sym(0);
kf=sym(1);
for k=sym(1):sym(first+1)
kf=kf*(k+1);
s3=s3+k/kf;
end
% s3
digits 7000
(1-s2)/(1-s3)
fprintf('%85.80f\n',(1-vpa(s2))/(1-vpa(s3)))
end
The cases of 4 and 5, 5 and 6, ... , 12 and 13 are done before going on to 2022 and 2023:
ans =
6
6.00000000000000000000000000000000000000000000000000000000000000000000000000000000
ans =
7
7.00000000000000000000000000000000000000000000000000000000000000000000000000000000
ans =
8
8.00000000000000000000000000000000000000000000000000000000000000000000000000000000
ans =
9
9.00000000000000000000000000000000000000000000000000000000000000000000000000000000
ans =
10
10.00000000000000000000000000000000000000000000000000000000000000000000000000000000
ans =
11
11.00000000000000000000000000000000000000000000000000000000000000000000000000000000
ans =
12
12.00000000000000000000000000000000000000000000000000000000000000000000000000000000
ans =
13
13.00000000000000000000000000000000000000000000000000000000000000000000000000000000
ans =
14
14.00000000000000000000000000000000000000000000000000000000000000000000000000000000
ans =
2024
2024.00000000000000000000000000000000000000000000000000000000000000000000000000000000
The fraction value is always 1 higher than the higher of the two n values. In the case asked for, the answer is 2024.
|
Posted by Charlie
on 2024-05-10 10:29:44 |