schoolmath

In 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.

7 Responses to “schoolmath”

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

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

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

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

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

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

  6. Giles Warrack Says:

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

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 677 other followers