Egypt algorithm put in own functions