Skip to main content
3 of 5
Included the continued fractions as well as the convergents for a significant score improvement
Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179

CJam (2780 sequences)

{:ZA3#:Cb(40-_!!:B-\+CbB)/C),{mq_i>},=:NmQ:M;K{)[N0{N1$_*-@/M@+1$md@M@-}K*]<W%B{X0@{2$*+\}%}*ZB&=}%} 

This gives correct answers for the inclusive ranges

  • [A040002, A040003]

  • [A040005, A040008]

  • [A040011, A040013]

  • A040015

  • [A040019, A040022]

  • A040024

  • [A040029, A040033]

  • A040035

  • A040037

  • [A040041, A040043]

  • A040048

  • A040052

  • [A040055, A040057]

  • A040059

  • A040063

  • [A040071, A040074]

  • A040077

  • A040080

  • [A040090, A040091]

  • [A040093, A040094]

  • A040099

  • [A040109, A040111]

  • A040118

  • A040120

  • [A040131, A040135]

  • A040137

  • A040139

  • [A040142, A040143]

  • A040151

  • [A040155, A040157]

  • A040166

  • A040168

  • [A040181, A040183]

  • [A040185, A040968]

  • [A041006, A041011]

  • [A041014, A042937]

The A040??? sequences correspond to the continued fractions of non-rational square roots from sqrt(5) to sqrt(1000) (with the gaps corresponding to ones which appear earlier in OEIS, but conveniently filled with random sequences); the A041??? sequences correspond to the numerators and denominators of the continued fraction convergents for non-rational square roots from sqrt(6) to sqrt(1000) (with the gap corresponding to sqrt(10), at A005667 and A005668).

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

It was tricky to map 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. The trick I used in an earlier version to have an all-zero fallback for out-of-range indices no longer fits: it took me a couple of hours just to get both continued fractions and convergents into the 100 byte limit.

Peter Taylor
  • 43.4k
  • 4
  • 72
  • 179