pari-gp

Calling PARI/GP from Python

删除回忆录丶 提交于 2021-02-07 03:27:31
问题 I would like to call PARI/GP from Python only to calculate the function nextprime(n) for different n s that I define. Unfortunately I can't get pari-python to install so I thought I would just call it using a command line via os.system in Python. I can't see in the man page how to do get PARI/GP to run in non-interactive mode, however. Is there a way to achieve this? 回答1: You can pipe input into gp's stdin like so, using the -q flag to quash verbosity: senderle:~ $ echo "print(isprime(5))" |

How to check if a number is an integer in Pari/GP?

僤鯓⒐⒋嵵緔 提交于 2020-01-17 06:18:12
问题 I'm trying to write an if statement like this if(denominator([(i-1)! + 1] / i)-1,print(hi),print(ho)) i can be any integer for example 10, when I set i to 10 it gives this error. ? [(x-1)! + 1] / x *** this should be an integer: [(x-1)!+1]/x ^----------- I really only need to check if [(x-1)! + 1] / x is an integer or not the denominator thing is what I came up with, I also tried Mod but couldn't get that working either. 回答1: It seems that you are confused with the names x and i . Please, see

Finding entry of vector in PARI/GP?

别等时光非礼了梦想. 提交于 2020-01-04 06:23:12
问题 With PARI/GP, if I have a vector with unique entries: a = [9, 7, 3, 5, 2, 8, 1, 0, 11] how do I get the position (index) of an entry in the vector a ? like: i = vectorsearch(a, 8); a[i] %1 = 8 Converting into a set and using setsearch doesn't work! 回答1: Just do select((x) -> x == 8, a, 1) where flag 1 means the "index mode". In general, your function is as shown below. position = (elt, array) -> select((x) -> x == elt, array, 1); Please note, despite the fact that this stuff does a lambda

Is there an algorithm known for power towers modulo a number managing all cases?

﹥>﹥吖頭↗ 提交于 2019-12-21 21:18:11
问题 I would like to have an implementation in PARI/GP for the calculation of a_1 ^ a_2 ^ ... ^ a_n (mod m) which manages all cases, especially the cases where high powers appear in the phi-chain. Does anyone know such an implementation ? 来源: https://stackoverflow.com/questions/21305782/is-there-an-algorithm-known-for-power-towers-modulo-a-number-managing-all-cases

Is there an algorithm known for power towers modulo a number managing all cases?

拈花ヽ惹草 提交于 2019-12-04 17:01:14
I would like to have an implementation in PARI/GP for the calculation of a_1 ^ a_2 ^ ... ^ a_n (mod m) which manages all cases, especially the cases where high powers appear in the phi-chain. Does anyone know such an implementation ? 来源: https://stackoverflow.com/questions/21305782/is-there-an-algorithm-known-for-power-towers-modulo-a-number-managing-all-cases