Max Alekseyev on Thu, 01 Sep 2022 22:04:10 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

nice undocumented features of t_INTMOD


By pure chance I've discovered the following two undocumented features, which I find quite useful.
I think it is worth describing them in the documentation of forstep() and operation % respectively.

1) t_INTMOD can be used as a step in forstep() for iterating over integers in the given interval belonging to the given congruence class - like:

? forstep(k=1,100,Mod(7,10), print(k) )
7
17
27
37
47
57
67
77
87
97

2) t_INTMOD can be used as x in "x % y" with an integer y. If I got it correctly, it results in the modulus of x being reduced to gcd(x.mod,y), i.e. Mod(lift(x),gcd(x.mod,y)) - like:

? Mod(13,21) % 70
%1 = Mod(6, 7)

This may be particularly useful when y divides x.mod to quickly find a congruence class modulo y that contains x.

PS. Btw, "?%" in GP gives the help message "last history item." while "??%" brings up the documentation about operation %.

Regards,
Max