Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Pari gp 中有一个代码,它搜索(a(x),b(x))给定值的对,x使它们成为素数。如何返回使两者都为素数的 ia(x)的b(x)总数
(a(x),b(x))
x
a(x)
b(x)
a(x) =x power 8 + 1 b(x) = x power 10 + 1 for (i=2,5,if(isprime(a(x)==1,if(isprime(b(x)==1,print([i,ax,bx]))
你的代码不起作用。a、b 的定义不是 PARI;括号不匹配;x 和 i 是否打算相同?如果不是,x 是什么?
第二个问题是 b(i) 永远不会是素数,因为factor(x^10 + 1)它有两个不同的因素。
factor(x^10 + 1)
如果我了解您要完成的工作,我建议以下内容,但由于上述原因,答案始终为 0。
a(x)=x^8 + 1 b(x)=x^10 + 1 sum(i=2,100,isprime(a(i)) && isprime(b(i)))