Skip to content

Commit

Permalink
Add Project Euler problem #63 Dlang solution
Browse files Browse the repository at this point in the history
  • Loading branch information
menjaraz authored Sep 1, 2024
1 parent 64394cf commit d4dd0ea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pe-0063/dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"description": "Project Euler #63 - D Solution",
"name": "pe-0063"
}
24 changes: 24 additions & 0 deletions pe-0063/source/app.d
Original file line number Diff line number Diff line change
@@ -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"());
}

0 comments on commit d4dd0ea

Please sign in to comment.