First solution, #1.
A bit faster - skip a few number, #1.
#2