+ 2

Challenge : Square Rooting Natural Numbers

This question got me thinking for a while and I've got a solution myself but I wanted to see how the Masters of SoloLearn will deal with this. So the challenge is simple : If you try to calculate square root of some number like 12 which does not come out of the root like 4 does.( sqrt(4)=2, but sqrt(12)=3.46410161514 ). The challenge is to write a code that for example when the input is 12, it will return "2√3". I think it is a bit tricky but let's see what you can do ;)

12th Aug 2017, 10:02 PM
Mehmet
Mehmet - avatar
6 Respostas
12th Aug 2017, 10:24 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 2
©Mehmet done :)
13th Aug 2017, 9:13 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
13th Aug 2017, 5:43 AM
Raul Uriarte
Raul Uriarte - avatar
+ 1
@Baptiste E. Prunier, nice code very short but I think you can improve it. When the input is a squared number like 4,25,36, it could write 2,5,6 not only sqrt(25).
13th Aug 2017, 9:04 AM
Mehmet
Mehmet - avatar
+ 1
@Raul Uriarte Very nice one, similar to what I wrote the other day. Separating inside and outside is really smart :) You may use the root symbol "√" to make the output prettier :D
13th Aug 2017, 9:08 AM
Mehmet
Mehmet - avatar
14th Aug 2017, 11:28 AM
Daniil Bannoni Mukhachev
Daniil Bannoni Mukhachev - avatar