Does anybody know of a way to generate the Erdos Function e.g.

int Erdos(int n) { ? }

I have tried a few algorithms but none seem to give the correct results:

e.g. Erdos(2) = 2, Erdos(9) = 3, Erdos (12) = 3, Erdos(10) = 5.

Any ideas would be great.