Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pari-result-279.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
26
16
6
2
6
16
26
 *** [...] at: ...,6,if(n==2,16,if(n==1,26,a(n-8))))))))
 *** ^-------------
 *** in function a: ...,6,if(n==2,16,if(n==1,26,a(n-8))))))))
 *** ^-------------
 *** in function a: ...,6,if(n==2,16,if(n==1,26,a(n-8))))))))
 *** ^-------------
*** deep recursion.
*** Break loop: type 'break' to go back to GP prompt
[?2004hbreak> [?2004l[?2004h
Expand Down
16 changes: 16 additions & 0 deletions pari-result-745.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
26
16
6
2
6
16
26
 *** [...] at: ...,6,if(n==2,16,if(n==1,26,a(n-8))))))))
 *** ^-------------
 *** in function a: ...,6,if(n==2,16,if(n==1,26,a(n-8))))))))
 *** ^-------------
 *** in function a: ...,6,if(n==2,16,if(n==1,26,a(n-8))))))))
 *** ^-------------
*** deep recursion.
*** Break loop: type 'break' to go back to GP prompt
[?2004hbreak> [?2004l
7 changes: 7 additions & 0 deletions src/form/formula_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,13 @@ int64_t getNumInitialTermsNeeded(int64_t cell, const std::string& fname,
int64_t terms_needed = 0;
if (stateful.find(cell) != stateful.end()) {
terms_needed = (ie.getLoopCounterDecrement() * stateful.size());
// For the counter cell (main function in periodic sequences), add one
// additional initial term to complete the recurrence period. This ensures
// that for a recurrence a(n) = a(n-k), we have k initial terms to avoid
// deep recursion in PARI evaluation.
if (cell == ie.getSimpleLoop().counter) {
terms_needed += ie.getLoopCounterDecrement();
}
}
return terms_needed;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/programs/oeis/131/A131083.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; A131083: Periodic sequence (26, 16, 6, 2, 6, 16, 26, 30).
; Submitted by loader3229
; 26,16,6,2,6,16,26,30,26,16,6,2,6,16,26,30,26,16,6,2,6,16,26,30,26,16,6,2,6,16,26,30,26,16,6,2,6,16,26,30,26,16,6,2,6,16,26,30,26,16,6,2,6,16,26,30,26,16,6,2,6,16,26,30,26,16,6,2,6,16,26,30,26,16,6,2,6,16,26,30
; Formula: a(n) = a(n-8), a(7) = 26, a(6) = 16, a(5) = 6, a(4) = 2, a(3) = 6, a(2) = 16, a(1) = 26

#offset 1

mov $2,26
mov $3,16
mov $4,6
mov $5,2
sub $0,1
lpb $0
mul $2,-1
rol $2,4
add $5,32
sub $0,1
lpe
mov $0,$2