Questions tagged [pari-gp]

Questions about the computer algebra system PARI/GP, including questions about the GP scripting language and the gp interactive shell. Please use the tag [pari] for the PARI C library.

The description in the tag exerpt is a direct quotation from the PARI/GP Development Headquarters, taken on Apr. 5, 2013. This tag is intended for questions about the computer algebra system PARI/GP, including questions about the GP scripting language and the gp interactive shell. See the separate tag for the PARI C library.

114 questions
0
votes
1 answer

Pari GP - Checking if user keyed in a prime number

I am currently learning how to use Pari GP and right now i am trying to write out a code on checking whether if the user did key in a prime number or not. Here is my code. printf("\t%s \n","PrimeNo(P): To check if it is a prime or…
James Quek
  • 15
  • 3
0
votes
1 answer

Dynamic array in GP/PARI

I need to calculate number of primes from 1 to N. For this i want to divide every next number n for primes in range 2 to sqrt(n). For this, in turn, i need to store all previously collected primes. How can i store them effectively? Just in case,…
Yola
  • 18,496
  • 11
  • 65
  • 106
0
votes
1 answer

bestappr function gives incorrect answer in pari/gp

bestappr(sqrt(13),30) gives 18/5 for any precision I tried, but a closer approximation is 101/28. Is there anything I missed?
user4340463
0
votes
2 answers

PARI/GP: How to get the max prime factor of the integer?

I am new to pari/gp. I use factorint to find all the prime factors and it returns a matrix. I am trying to traverse through a matrix to find the largest number inside but unable to find the length of rows and columns. Also how can i use the if to…
Tommy Yap
  • 85
  • 1
  • 9
0
votes
2 answers

Checking if a returned number is an integer in GP/Pari?

This is my first time using GP/Pari and I am having trouble completing this question. I am asked to print if the return of the function 'wq()' is an integer. Is there a function that can determine if the number passed in is an integer? If not how…
0
votes
3 answers

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

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 …
0
votes
2 answers

pari gp return function store in variable

I'm new to pari gp, and just trying out, playing with it. i have an inverse function that goes like this. inverse (a,n) = { negative = false; if (a < 0, negative = true); if (a < 0, a= a*-1); i = n; v = 0; d = 1; while (a>0,t=i/a;…
0
votes
3 answers

Pari/GP compare integer with real

I want to test if an integer is a perfect power in Pari-gp. The test sqrt(n)==floor(sqrt(n)) works fine for testing squares, but it fails for every other power: sqrtn(n,k)==floor(sqrtn(n,k)) with k >=3. I think it maybe since one number is real and…
Beni Bogosel
  • 572
  • 1
  • 6
  • 22
-1
votes
1 answer

how to move to the next loop in PARI/GP if I use multi-line nested for loops?

my question is: how to move to the next loop in PARI/GP if I use multi-line nested for loops ? for example : if I use this code : for(K=1,10,for(i=1,5,if(isprime(2*i*prime(K)+1)==1,print(2*i"*"prime(K))))) and since 2*(i=1)*prime(K=1)+1=5 is prime,…
1 2 3 4 5 6 7
8