EDIT: Thanks to everyone who answered, but I did not do a good enough search for questions like mine and in fact there was someone else who asked the exact same question. The second linked question is essentially the same as mine and even has similar answers. Thanks!
I'm using a website called Anydice, and they allow some basic math operations, but do not have square roots. I would like to use a square root but now I'm more interested in trying to make one with the operations they have. The website can do:
• Addition
• Subtraction
• Multiplication
• Integer division $\left(\frac{6}{3 }= 2\right.$, while $\frac{1}{2} = 1$. The answers are always integers.$\left.\right)$
• And Exponentiation
Additonally, it doesn't seem to like decimals, only integers are allowed. This means I can't do something like $4^\left(\frac{1}{2}\right)$ or $4^\left(0.5\right)$.
In additon to those operations, the program can:
• Create and edit variables
• Enter and exit loops
• Compare values $\left(\gt, \lt, =, \ge, \le\right)$
• Create conditionals (if, then, else)
• Create functions of code
Is it possible, with this set of rules, to create a square root? Can I find $\sqrt{25}=5$ in Anydice?
EDIT: I am aware that a square root can be represented by $x^{\frac{1}{2}}$ or $x^{0.5}$, as well as the fact that $\sqrt x$ can be computed as $10^\left(\frac{log_{10}x}{2}\right)$. The first two are rejected for reasons explained above, while the last example requires an operation I don't have access to. My research showed that computing the log function is usually done by addition of infinite sets of fractions, which is also impossible.
I'm already starting to think that this cannot be done, but I'm interested enough to wait and see if anyone can think of anything.
Variables and loops, you say?
When the loop exits, $r$ will be $\sqrt n$, rounded down. It's slow and stupid, but it'll get the job done. I'm also guessing you're only using it for small values of $n$, so the inefficiency won't be too painful.
The code's written assuming you have only the most basic loop constructs (i.e. no
whileloops, fixed number of iterationforloops, nobreaking out of loops.) You can make this a bit nicer if you can use any of those, but it's still "count up one at a time, and stop when $r*r$ gets larger than $n$".