Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
49
Task/Mian-Chowla-sequence/XPL0/mian-chowla-sequence.xpl0
Normal file
49
Task/Mian-Chowla-sequence/XPL0/mian-chowla-sequence.xpl0
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
define N = 100;
|
||||
define NN = (N * (N+1)) >> 1;
|
||||
|
||||
func Contains(Lst, Item, Size);
|
||||
int Lst, Item, Size, I;
|
||||
[for I:= Size-1 downto 0 do
|
||||
if Item = Lst(I) then return true;
|
||||
return false;
|
||||
];
|
||||
|
||||
int MC(N);
|
||||
|
||||
proc MianChowla;
|
||||
int Sums(NN), Sum, LE, SS, I, J, K;
|
||||
[MC(0):= 1;
|
||||
Sums(0):= 2;
|
||||
SS:= 1;
|
||||
for I:= 1 to N-1 do
|
||||
[LE:= SS;
|
||||
J:= MC(I-1) + 1;
|
||||
MC(I):= J;
|
||||
K:= 0;
|
||||
loop [Sum:= MC(K) + J;
|
||||
if Contains(Sums, Sum, SS) then
|
||||
[SS:= LE;
|
||||
J:= J+1;
|
||||
MC(I):= J;
|
||||
K:= 0;
|
||||
]
|
||||
else
|
||||
[Sums(SS):= Sum;
|
||||
SS:= SS+1;
|
||||
K:= K+1;
|
||||
if K > I then quit;
|
||||
];
|
||||
];
|
||||
];
|
||||
];
|
||||
|
||||
int I;
|
||||
[MianChowla;
|
||||
Text(0, "The first 30 terms of the Mian-Chowla sequence are:^m^j");
|
||||
for I:= 0 to 30-1 do
|
||||
[IntOut(0, MC(I)); ChOut(0, ^ )];
|
||||
Text(0, "^m^j^m^jTerms 91 to 100 of the Mian-Chowla sequence are:^m^j");
|
||||
for I:= 90 to 100-1 do
|
||||
[IntOut(0, MC(I)); ChOut(0, ^ )];
|
||||
CrLf(0);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue