Skip to main content
1 of 5
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179

CJam (2182 sequences)

{:Z2/20500-A3#),{mq_i>},{;2}j:Q[:NmQ:M1M{N1$_*-@/M@+1$md@M@-}J*;;]K,:)\f<{W%X0@{2$*+\}/}%2/zZ=Q2>f*} 

This gives correct answers for the inclusive ranges [A041006, A041011], [A041014, A042937], and the 252 which start with 20 zeroes. The two ranges of interest correspond to the numerators and denominators of continued fraction convergents of non-rational square roots from sqrt(6) to sqrt(1000) except sqrt(10), which is elsewhere (A005667, A005668) but for which they conveniently left a gap to be filled with random sequences (A041012, A041013).

The answer ports elements of two earlier answers of mine in GolfScript:

The trickiest part was mapping the sequence number to the value to sqrt. In the end I couldn't find anything better than generating the list of non-squares and selecting by index. However, this does allow a little trick: instead of using = for the get-array-item operator, I'm using {;2}j, abusing the memoisation operator to provide a fallback value of 2 for any index out of the range of interest. At the end I detect this fallback value to replace the convergents with all-zeroes.

Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179