1

I have Pari/GP 32-bit and would like to implement any type of code which runs for a limited amount of time, then automatically stops if nothing is produced by that time. Here is a pseudocode example:

command
...
run command
if run time over 3 minutes
automatically interrupt the program and stop running

I know there is a basic way to do this, I just never found it in the PARI/GP guide. Any help? Thanks.

Andrew
  • 873
  • 4
  • 10
J. Linne
  • 275
  • 4
  • 15

1 Answers1

2
 alarm(5);for(i=1,10^10,continue)
Andrew
  • 873
  • 4
  • 10
  • You can also move the code inside the `alarm` function, as a second argument. For example `alarm(5, factor(2^1234+1))` will return the full factorization of `2^1234+1` if it can be produced in 5 seconds, or will return (not raise) an error object otherwise. – Jeppe Stig Nielsen Sep 01 '19 at 22:29