Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Hofstadter-Q-sequence/PL-I/hofstadter-q-sequence-1.pli
Normal file
20
Task/Hofstadter-Q-sequence/PL-I/hofstadter-q-sequence-1.pli
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* Hofstrader Q sequence for any "n". */
|
||||
|
||||
H: procedure options (main); /* 28 January 2012 */
|
||||
declare n fixed binary(31);
|
||||
|
||||
put ('How many values do you want? :');
|
||||
get (n);
|
||||
|
||||
begin;
|
||||
declare Q(n) fixed binary (31);
|
||||
declare i fixed binary (31);
|
||||
|
||||
Q(1), Q(2) = 1;
|
||||
do i = 1 upthru n;
|
||||
if i >= 3 then Q(i) = ( Q(i - Q(i-1)) + Q(i - Q(i-2)) );
|
||||
if i <= 20 then put skip list ('n=' || trim(i), Q(i));
|
||||
end;
|
||||
put skip list ('n=' || trim(i), Q(i));
|
||||
end;
|
||||
end H;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
declare tally fixed binary (31) initial (0);
|
||||
|
||||
do i = 1 to n-1;
|
||||
if Q(i) > Q(i+1) then tally = tally + 1;
|
||||
end;
|
||||
put skip data (tally);
|
||||
Loading…
Add table
Add a link
Reference in a new issue