corrected a useless mistake in p5 ranges used and added the naive solution, but left it commented out as it is way too slow