bug in schoolmath

June 13, 2010
By

(This article was first published on Xi'an's Og » R, and kindly contributed to R-bloggers)

Neil 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

This is rather annoying and I hope it gets quickly fixed!

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

To leave a comment for the author, please follow the link and comment on their blog: Xi'an's Og » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, 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: , , , ,

Comments are closed.

Sponsors

Mango solutions



RStudio homepage



Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training



http://www.eoda.de







ODSC

ODSC

CRC R books series





Six Sigma Online Training





Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)