Data Update
This commit is contained in:
parent
015c2add84
commit
e50b5c3114
206 changed files with 6337 additions and 523 deletions
12
Task/Sylvesters-sequence/J/sylvesters-sequence.j
Normal file
12
Task/Sylvesters-sequence/J/sylvesters-sequence.j
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
2 ('Sum of reciprocals: ' , ":@:(+/))@:%@:([ echo&>)@:((, 1x + */)@[&_~) 9
|
||||
2
|
||||
3
|
||||
7
|
||||
43
|
||||
1807
|
||||
3263443
|
||||
10650056950807
|
||||
113423713055421844361000443
|
||||
12864938683278671740537145998360961546653259485195807
|
||||
165506647324519964198468195444439180017513152706377497841851388766535868639572406808911988131737645185443
|
||||
Sum of reciprocals: 27392450308603031423410234291674686281194364367580914627947367941608692026226993634332118404582438634929548737283992369758487974306317730580753883429460344956410077034761330476016739454649828385541500213920805r27392450308603031423410234291674686281194364367580914627947367941608692026226993634332118404582438634929548737283992369758487974306317730580753883429460344956410077034761330476016739454649828385541500213920806
|
||||
27
Task/Sylvesters-sequence/Pascal/sylvesters-sequence.pas
Normal file
27
Task/Sylvesters-sequence/Pascal/sylvesters-sequence.pas
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
program SylvesterSeq;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses SysUtils,
|
||||
UIntX; // in the library IntX4Pascal
|
||||
(*
|
||||
As noted in the Wikipedia article "Sylvester's sequence", we have
|
||||
1/2 + 1/3 + ... + 1/s[j-1] = (s[j] - 2)/(s[j] - 1),
|
||||
so that instead of summing the reciprocals explicitly we can just
|
||||
calculate an extra term.
|
||||
*)
|
||||
var
|
||||
s : UIntX.TIntX; // arbitrarily large integer
|
||||
i : integer;
|
||||
begin
|
||||
s := 1;
|
||||
for i := 0 to 9 do begin
|
||||
inc(s);
|
||||
WriteLn( SysUtils.Format( 's[%d] = %s', [i, s.ToString]));
|
||||
s := s*(s - 1);
|
||||
end;
|
||||
WriteLn( 'Sum of reciprocals =');
|
||||
WriteLn( (s - 1).ToString);
|
||||
WriteLn( '/'); // on a separate line for clarity
|
||||
WriteLn( s.ToString);
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue