diff --git a/pe-0063/dub.json b/pe-0063/dub.json new file mode 100644 index 0000000..76e2a9f --- /dev/null +++ b/pe-0063/dub.json @@ -0,0 +1,4 @@ +{ + "description": "Project Euler #63 - D Solution", + "name": "pe-0063" +} \ No newline at end of file diff --git a/pe-0063/source/app.d b/pe-0063/source/app.d new file mode 100644 index 0000000..291755f --- /dev/null +++ b/pe-0063/source/app.d @@ -0,0 +1,24 @@ +// Powerful Digit Counts +// https://projecteuler.net/problem=63 + +import std.stdio; +import std.datetime.stopwatch; +import std.math; + +void main() { + auto timer = StopWatch(AutoStart.yes); + + int totalCount = 0; + + foreach (i; 1 .. 10) { + real log_i = log10(cast(real)i); + int count = cast(int) floor(1.0 / (1.0 - log_i)); + + totalCount += count; + } + + timer.stop(); + + writefln("\nProject Euler #63\nAnswer: %s", totalCount); + writefln("Elapsed time: %s milliseconds.\n", timer.peek.total!"msecs"()); +}