tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
13
Task/Nth-root/Smalltalk/nth-root-1.st
Normal file
13
Task/Nth-root/Smalltalk/nth-root-1.st
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Number extend [
|
||||
nthRoot: n [
|
||||
|x0 m x1|
|
||||
x0 := (self / n) asFloatD.
|
||||
m := n - 1.
|
||||
[true] whileTrue: [
|
||||
x1 := ( (m * x0) + (self/(x0 raisedTo: m))) / n.
|
||||
((x1 - x0) abs) < ((x0 * 1e-9) abs)
|
||||
ifTrue: [ ^ x1 ].
|
||||
x0 := x1
|
||||
]
|
||||
]
|
||||
].
|
||||
3
Task/Nth-root/Smalltalk/nth-root-2.st
Normal file
3
Task/Nth-root/Smalltalk/nth-root-2.st
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(34 nthRoot: 5) displayNl.
|
||||
((7131.5 raisedTo: 10) nthRoot: 10) displayNl.
|
||||
(7 nthRoot: 0.5) displayNl.
|
||||
Loading…
Add table
Add a link
Reference in a new issue