1||0|126|0| 0|0|0|||||Josephus Flavius %28correction%29|David Turner|1|08:17:15|05/14/2008|Sorry%2C I transcribed the last case of the mathematical version of the solution incorrectly%3B it should have been %28f%28n-q%2C p%29 - r%29%28p%2F%281-p%29%29. A clearer statement is as follows%3A%0D%0A%0D%0A%5Bpre%5D%0D%0Alet q%28n%2C p%29 %3D %28q - r%28n%2C p%29%29%2Fp%2C%0D%0A r%28n%2C p%29 %3D n %28mod p%29%2C%0D%0A g%28n%2C p%29 %3D f%28n - q%28n%2C p%29%2C p%29 - r%28n%2C p%29%0D%0Athen f%28n%2C p%29 is defined piecewise as%3A%0D%0A 0%2C n %3D 1%0D%0A f%28n - 1%2C p%29 %2B p %28mod n%29%2C n %3C p%0D%0A g%28n%2C p%29 %2B n%2C g%28n%2C p%29 %3C 0%0D%0A g%28n%2C p%29 %2B q%28g%28n%2C p%29%2C p - 1%29%29 otherwise.%0D%0A%5B%2Fpre%5D%0D%0A%0D%0AMy e-mail address is dkturner%40gmail.com%2C let me know if you need further explanation%2C and especially if you have a better way of stating the definition of f %3A-%29 1|1|0|||||RE%3A Josephus Flavius %28correction%29|alexb||09:42:47|05/14/2008|I do not know whether there is any better way to define your function. But you may want to check %28if you have not yet%29 with the %22Project Euler%22 site %28http%3A%2F%2Fprojecteuler.net%2F%29 which is specifically designed to consider problems whose solution may require programming and computer experimentation.