Skip to main content
6 of 10
added 84 characters in body
Kosatka
  • 121
  • 4

Brainlove, 73 70 bytes

Because brainfuck is too hard

-3 bytes by myself, rearranging the memory and fixing some bugs

(<->~)[[->+>+<<]>[<+>-]<-]>+>>+[<<[>-(>-<~)<<+>-]<[>+<-]>++>>>+<]>[-~] 

Try it online

First computes the sum $$ S = \sum_{i=1}^n i = \frac{n(n+1)}{2} $$ and then the square root by finding the largest n for which $$ \sum_{i=1}^n 2i-1 = n^2 < S $$ The error is always $$ E= \sqrt{\frac{n(n+1)}{2}}- \frac{n}{\sqrt{2}} < \sqrt{\frac{(n+\frac{1}{2})^2}{2}} - \frac{n}{\sqrt{2}} = \frac{n+\frac{1}{2}-n}{\sqrt{2}} = \frac{\sqrt{2}}{4} $$ and it is counteracted by rounding down. It is not very golfed, since I'm not very familiar with golfing in Brainlove/brainfuck, any improvements welcome (or a bf version). It should theoretically work for unbound cells (arbitrary precision), but I didn't have an option to test that.

Unary output version, can handle printing numbers bigger than 10

Kosatka
  • 121
  • 4