[R] Modulus Problem
McGehee, Robert
Robert.McGehee at geodecapital.com
Wed Dec 8 17:59:52 CET 2004
R users, I am having a problem with the modulus operator for large
numbers as follows,
a <- 2
n <- 561
## n is the first Carmichael number, so by Fermat's Little Theorem the
below should equal zero.
(a^(n-1) - 1) %% n
[1] 2.193172e+152
## Seems that R and Fermat disagree
## Also,
1000000000000000000 %% 11
[1] -32
This seems like a bug. Should I be avoiding integer math for large
numbers?
Thanks,
Robert
platform i686-pc-linux-gnu
arch i686
os linux-gnu
system i686, linux-gnu
status
major 2
minor 0.1
year 2004
month 11
day 15
language R
More information about the R-help
mailing list