## schoolmath

**I**n connection with the Le Monde puzzle of last week, I was looking for an R function that would give me the prime factor decomposition of any integer. Such a function exists within the package schoolmath, developped by Joerg Schlarmann and Josef Wienand. It is called prime.factor and it returns the prime factors of any integer:

> prime.factor(2016)

[1] 2 2 2 2 2 3 3 7

> prime.factor(2032)

[1] 2 2 2 2 127

> prime.factor(2031)

[1] 3 677

> prime.factor(2039)

2039 is a prime!

[1] 2039

**Warning [06/14/10]!** *As pointed out in this blog** by Neil Gunther, schoolmath contains mistakes in the function primes, listing 1 as a prime number but also including decomposable numbers like 133.*

February 18, 2011 at 12:09 am

[...] is prime and the overall sum is minimised. Here is a quick exploration by simulation, using the schoolmath package (with its [...]

October 18, 2010 at 12:11 am

[...] a function of the (still bugged!) schoolmath package. We thus have the [...]

October 18, 2010 at 12:11 am

[...] a function of the (still bugged!) schoolmath package. We thus have the [...]

June 14, 2010 at 7:37 am

[...] 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 [...]

March 31, 2010 at 3:20 pm

If it had not existed, one could also have downloaded free computer algebra systems, such as Xcas.

http://en.wikipedia.org/wiki/Xcas

March 7, 2010 at 1:09 pm

thanks for pointing this out. what else can schoolmath do?

March 7, 2010 at 5:47 pm

The name “says it all”! You can go all kinds of arithmetic high school stuff with the package…