Iterative Root

Submit

Your name:
File:
Open code-statistics:

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

Ruby _

RankUserSizeTimeDateStatistics
1rotary-o910.01732025/02/10 12:16:150B / 34B / 52B

Ruby2 _

RankUserSizeTimeDateStatistics
1rotary-o850.10532025/02/10 12:16:020B / 31B / 49B

Perl _

RankUserSizeTimeDateStatistics
1tails920.01612025/01/30 12:17:340B / 31B / 61B

Python3 _

RankUserSizeTimeDateStatistics
1b1851310.04602025/01/31 06:27:160B / 57B / 66B

C _

RankUserSizeTimeDateStatistics
1rotary-o1230.01392025/02/02 20:57:490B / 63B / 59B
2tails1260.01452025/01/30 12:17:500B / 63B / 62B
3McBusLuck1910.01532025/02/02 00:28:360B / 129B / 62B

Java _

RankUserSizeTimeDateStatistics
1rotary-o2070.05262025/02/02 21:44:410B / 141B / 65B

C# _

RankUserSizeTimeDateStatistics
1rotary-o2280.04052025/02/02 21:51:310B / 159B / 66B

Bash _

RankUserSizeTimeDateStatistics
1McBusLuck1070.00902025/02/02 00:39:2773B / 20B / 14B

Bash (builtins) _

RankUserSizeTimeDateStatistics
1tails1230.02192025/02/02 04:23:240B / 55B / 53B
2McBusLuck1500.02572025/02/02 01:25:330B / 82B / 62B

Zsh _

RankUserSizeTimeDateStatistics
1McBusLuck1070.00872025/02/02 00:38:2973B / 20B / 14B

Nibbles _

RankUserSizeTimeDateStatistics
1whio360.01972025/02/12 02:08:5921B / 12B / 3B
2tails (whio)330.02722025/02/12 13:18:3821B / 8B / 3B

Scala _

RankUserSizeTimeDateStatistics
1rotary-o1284.76042025/02/04 00:23:376B / 68B / 49B

Language Ranking_

RankLangUserSizeScore
1Nibblestails (whio)3310000
2Ruby2rotary-o853882
3Rubyrotary-o913626
4Perltails923586
5ZshMcBusLuck1073084
6BashMcBusLuck1073084
7Bash (builtins)tails1232682
8Crotary-o1232682
9Scalarotary-o1282578
10Python3b1851312519
11Javarotary-o2071594
12C#rotary-o2281447

return to the top page