Hot math: twin and sexy prime numbers

Just recently I discovered that there’s something called sexy prime numbers. I read about twin primes but hadn’t heard the other term before. The concept is pretty simple: take a prime number and check whether the next prime minus the first one results in a certain number, e.g. 2 for twin primes or 6 for sexy primes. This post presents a simple solution to calculate arbitrary combinations of prime number pairs, triplets, etc.

The Eclipse project with the code for this post can be downloaded as tar.gz or zip. You can browse the code online here.

Continue reading →

Friday the 13th with Joda Time

I’ve always wanted to try Joda Time and in this post I’d like to present some code that finds Friday the 13th dates. Wouldn’t it be interesting to know when the next Friday the 13th is or which year has got the most occurrences of this particular day?

The Eclipse project with the code for this post can be downloaded as tar.gz or zip. You can browse the code online here.

Continue reading →