Challenge
The goal of this challenge is to take a radical and convert it to a reduced and entire radical, and a real number. You do not have to convert it to all 3, however, you will get bonus points for converting it to 2 or 3 of them. You will also get bonus points if your code works not just with square roots. How the input works is your choice. You don't have to parse the input so you could just have it as a function. If your unable to output the root symbol (√) then you could output it as sqrt(x)
or cuberoot(x)
. You could also use a superscript (²√) for the index of the radical.
Rules
- If you just output one of the 3 options, then you can't just output it without converting it (ie: if the input is
√125
then you can't just output√125
back). - The entire radical must have no co-efficient.
- The mixed radical must have a coefficient (if there is no coefficient, then it should be
1
). - The real number (or result of the radical) should have as many decimals as possible.
Example
Here's an example output for the square root of 125 (√125):
Entire radical: √125
Mixed radical: 5√5
Real number: 11.18033988749895
Scoring
- 10% off your score for outputting 2 of either an entire radical, mixed radical, or real number.
- 30% off your score for outputting all 3 (entire radical, mixed radical, and real number).
- 30% off your score for working with a radical with any index
Winner
The person with the shortest code length wins. Good luck!