Iterative Root
Submit
Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.
Problem
Roots of the form x=A^-n can be iteratively approximated by using the formula x1=(1/n)*[(n-1)*x0 + A/x0^(n-1)] where x0 is an initial estimated value of x. By inserting the new estimate, x1, back into the formula in place of x0 the accuracy of the estimate is increased. Given a number A, root n, and initial estimate x0, show the results of this iterative approach until two consecutive x1 approximations produce the same result to three decimal places.
Options
exec is denied
rejudge feature is enabled
now post-mortem time, all source codes will be revealed
Sample input:_
142798,2,300
9,3,2
100,4,8
77,5,2
142,3,5
1000,6,5
Sample output:
387.997,378.018,377.886,377.886
2.083,2.080,2.080
6.049,4.650,3.736,3.281,3.169,3.162,3.162
2.563,2.407,2.384,2.384
5.227,5.217,5.217
4.220,3.641,3.295,3.175,3.162,3.162
Ranking
Rank | User | Size | Time | Date | Statistics |
---|
1 | tails | 92 | 0.0161 | 2025/01/30 12:17:34 | 0B / 31B / 61B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | b185 | 131 | 0.0460 | 2025/01/31 06:27:16 | 0B / 57B / 66B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | rotary-o | 123 | 0.0139 | 2025/02/02 20:57:49 | 0B / 63B / 59B |
2 | tails | 126 | 0.0145 | 2025/01/30 12:17:50 | 0B / 63B / 62B |
3 | McBusLuck | 191 | 0.0153 | 2025/02/02 00:28:36 | 0B / 129B / 62B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | tails | 123 | 0.0219 | 2025/02/02 04:23:24 | 0B / 55B / 53B |
2 | McBusLuck | 150 | 0.0257 | 2025/02/02 01:25:33 | 0B / 82B / 62B |
Language Ranking_
Rank | Lang | User | Size | Score |
1 | Nibbles | tails (whio) | 33 | 10000 |
2 | Ruby2 | rotary-o | 85 | 3882 |
3 | Ruby | rotary-o | 91 | 3626 |
4 | Perl | tails | 92 | 3586 |
5 | Zsh | McBusLuck | 107 | 3084 |
6 | Bash | McBusLuck | 107 | 3084 |
7 | Bash (builtins) | tails | 123 | 2682 |
8 | C | rotary-o | 123 | 2682 |
9 | Scala | rotary-o | 128 | 2578 |
10 | Python3 | b185 | 131 | 2519 |
11 | Java | rotary-o | 207 | 1594 |
12 | C# | rotary-o | 228 | 1447 |
return to the top page