Karim Belabas on Tue, 06 Mar 2018 00:45:13 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: forprime in arithmetic progressions? |
* Charles Greathouse [2018-02-28 20:13]: > The prime iterator (u_forprime_arith_init etc.) internally works in > arithmetic progressions. Would it be possible to expose this to the user? > (Perhaps "forprimestep", or maybe an optional final (INTMOD) argument to > forprime like prod.) > > This would be useful, not very hard to implement, and can't be efficiently > duplicated in gp. A first attempt is now committed to the 'master' branch. Please test ! The following two syntaxes are supported: ? forprimestep(p = 4, 40, 3, print(p)) 7 13 19 31 37 ? forprimestep(p = 4, 40, Mod(2,3), print(p)) 5 11 17 23 29 Notes : - The implementation is currently not very efficient : forprime() sieves are not supported yet [ as in the underlying u_forprime_arith_init ]. - The common difference in the arithmetic progression is restricted to an unsigned integer (i.e < 2^32 or 2^64) Cheers, K.B. -- Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 Universite de Bordeaux Fax: (+33) (0)5 40 00 21 23 351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/ F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP] `