aleaxit / gmpy

General Multi-Precision arithmetic for Python 2.6+/3+ (GMP, MPIR, MPFR, MPC)
https://gmpy2.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
516 stars 87 forks source link

About the case where `k=0` is input to `lucasu_mod` and `lucasv_mod` #445

Closed haru-44 closed 10 months ago

haru-44 commented 11 months ago

For lucasu_mod and lucasv_mod, it seems to be acceptable to input k=0 according to the description.

https://github.com/aleaxit/gmpy/blob/125310619ffc3cbf2a88a3b9121ea74b8e295ec3/src/gmpy_mpz_lucas.c#L185-L188

However, it does not seem to be expected that k=0 is actually input.

skirpichev commented 10 months ago

Same for lucasu/v, they just spin forever.

casevh commented 10 months ago

Since it looks like it works for k>0, I'll just check for k==0 and return the correct value.

For reference, see https://en.wikipedia.org/wiki/Lucas_sequence