A few years ago a friend of mine asked me the following Perl riddle. Unfortunately, in order to solve it you must know Perl. As I like Python much better, I translated the riddle to Python. Attached are both versions.
I admit the Perl version is a bit more cryptic and if you know both Perl and Python you should try to solve the Perl version (but use Python for everything else in life ).
Oh, and try to solve the riddle without running it (run it only as a last resort).
perl -wle 'print "True" if (1 x shift) !~ /^1?$|^(11+?)\1+$/' [number]
python -c "import sys, re; print None == re.match('^1?$|^(11+?)\\1+$','1'*int(sys.argv))" [number]
To alleviate all doubt – [number] denotes a numeric command line argument (e.g. 17).