Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
13
Task/Euler-method/Nim/euler-method.nim
Normal file
13
Task/Euler-method/Nim/euler-method.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import strutils
|
||||
|
||||
proc euler(f: proc (x,y: float): float; y0, a, b, h: float) =
|
||||
var (t,y) = (a,y0)
|
||||
while t < b:
|
||||
echo formatFloat(t, ffDecimal, 3), " ", formatFloat(y, ffDecimal, 3)
|
||||
t += h
|
||||
y += h * f(t,y)
|
||||
|
||||
proc newtoncooling(time, temp): float =
|
||||
-0.07 * (temp - 20)
|
||||
|
||||
euler(newtoncooling, 100.0, 0.0, 100.0, 10.0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue