(PARI)eva(n)=替代(Pol(n),x,10)
find_index_a(vec)=我的(r=#vec-1);而(1,如果(vec[r]<vec[r+1),返回(r));r--;如果(r==0,返回(-1))
find_index_b(r,vec)=我的(s=#vec);而(1,如果(vec[r]<vec[s],返回(s));s--;如果(s==r,返回(-1))
switch_elements(vec,firstpos,secondpos)=我的(g);g=vec[第二位置];vec[secondpos]=vec[firstpos];vec[firstpos]=g;血管内皮细胞
反向顺序(vec,r)=my(v=[],w=[]);对于(x=1,r,v=concat(v,vec[x]));对于(y=r+1,#vec,w=concat(w,vec[y]));w=Vecrev(w);凹面(v,w)
next_permutation(vec)=我的(r=find_indexa(vec));如果(r==-1,返回(0),my(s=findindexb(r,vec));vec=开关元素(vec,r,s);vec=反向次序(vec,r));血管内皮细胞
is(n)=如果(n<10,返回(1));my(d=vecsort(数字(n)));如果(vecmin(d)==0|vecmax(d)==1,则返回(0));while(1,如果(!ispseudoprime(eva(d)),则返回(0));d=下一个置换(d);如果(d==0,返回(1))
对于素数(p=1,如果(是(p),打印1(p,“,”))
|