f=lambda x,b=2:~-b*x in[i%b*~-b**(i/b)for i in range(b*x)]and b or f(x,-~b)%~-x for x in 11, 23, 55, 90, 91: print x, '-->', f(x)
Standard input is empty
11 --> 0 23 --> 0 55 --> 10 90 --> 14 91 --> 9
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!