Posts Tagged ‘ prime numbers ’

Lehmann Primiality Test in R

December 21, 2011
By

After a small frustration with the limitations of R 16-bit intergers. I think i have worked out a solution. The issue was i was implementing a bone-headed solution to the modulo/exponent step. So to recap. The Lehmann primality test is a probabilistic ...

Read more »

I may have ventured into the first circle and Virgil Is NOT Here — Lehmann Primality Test in R

December 20, 2011
By

So a post about Lehmann Primality Tests in HackerNews came across my twitter this morning. Seemed like a great quick coding exercise during lunch. Little Did I know…It is wonderfully simple primality test but i think i have hit up against some R quir...

Read more »

Ulam Spirals in R and ggplot

November 29, 2011
By
Ulam Spirals in R and ggplot

Having seen a twitter post speed by about Ulam Spirals I started to read up.  As the story goes in 1963 Stanislaw Ulam was bored at conference and started scribbling numbers in a spiral. What he discovered was a strange diaginal pattern of Prime Nu...

Read more »

Le Monde puzzle [#6]

February 17, 2011
By
Le Monde puzzle [#6]

A simple challenge in Le Monde this week: find the group of four primes such that any sum of three terms in the group is prime and the overall sum is minimised. Here is a quick exploration by simulation, using the schoolmath package (with its imperfections): A=primes(start=1,end=53) lengthA=length(A) res=4*53 for (t in 1:10^4){ B=sample(A,4,prob=1/(1:lengthA)) sto=is.prim(sum(B))

Read more »

bug in schoolmath

June 13, 2010
By
bug in schoolmath

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) 101 107 111 113 123 129 131 137 > primes(50,140)  

Read more »

schoolmath

March 6, 2010
By
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

Read more »