**N**eil Gunther has pointed out on his blog that the prime number decomposition R package schoolmath contains mistakes in the function primes, listing 1 as a prime number but also including decomposable numbers like 133 in its list of prime numbers:

> primes(100,140)

[1] 101 107 111 113 123 129 131 137

> primes(50,140)

[1] 51 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 **133**

[20] 137 139

> is.prim(primes(133)

[1] **FALSE**

> is.prim(primes(200,300))

[1] **FALSE** TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE **FALSE** TRUE

[13] TRUE TRUE TRUE TRUE TRUE TRUE

> sum(1-is.prim(primes(1,1000)))

[1] **10**

> data(primlist)

> sum(1-is.prim(primlist[1:25000]))

[1] **3309**

**T**his is rather annoying and I hope it gets quickly fixed!

Filed under: R Tagged: bug, prime factor decomposition, prime numbers, R, schoolmath

*Related*

To

**leave a comment** for the author, please follow the link and comment on his blog:

** Xi'an's Og » R**.

R-bloggers.com offers

**daily e-mail updates** about

R news and

tutorials on topics such as: visualization (

ggplot2,

Boxplots,

maps,

animation), programming (

RStudio,

Sweave,

LaTeX,

SQL,

Eclipse,

git,

hadoop,

Web Scraping) statistics (

regression,

PCA,

time series,

trading) and more...

If you got this far, why not

__subscribe for updates__ from the site? Choose your flavor:

e-mail,

twitter,

RSS, or

facebook...

**Tags:** bug, prime factor decomposition, prime numbers, R, schoolmath