A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
14
Task/Jensens-Device/D/jensens-device.d
Normal file
14
Task/Jensens-Device/D/jensens-device.d
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import std.stdio;
|
||||
|
||||
double sum(ref int i, in int lo, in int hi, lazy double term)
|
||||
pure @safe {
|
||||
double result = 0.0;
|
||||
for (i = lo; i <= hi; i++)
|
||||
result += term();
|
||||
return result;
|
||||
}
|
||||
|
||||
void main() {
|
||||
int i;
|
||||
writeln(sum(i, 1, 100, 1.0/i));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue