Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module factorialp;
- import pyd.pyd;
- import std.algorithm;
- import std.range;
- import std.bigint;
- import std.parallelism;
- import std.datetime;
- import std.stdio;
- BigInt factorial(int base) {
- auto chsize = base / totalCPUs / 4;
- BigInt result;
- auto starttime = Clock.currTime();
- auto result =
- taskPool.reduce!"a * b"(
- map!(fold!"cast(std.bigint.BigInt)a * b")
- (
- chunks(
- iota(1, base + 1),
- chsize ? chsize : 1
- )
- )
- );
- writefln("elapsed time = %s", Clock.currTime() - starttime);
- return result;
- }
- extern(C) void PydMain() {
- def!factorial();
- module_init();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement