Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Babbage-problem/D/babbage-problem.d
Normal file
23
Task/Babbage-problem/D/babbage-problem.d
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// It's basically the same as any other version.
|
||||
// What can be observed is that 269696 is even, so we have to consider only even numbers,
|
||||
// because only the square of even numbers is even.
|
||||
|
||||
import std.math;
|
||||
import std.stdio;
|
||||
|
||||
void main( )
|
||||
{
|
||||
// get smallest number <= sqrt(269696)
|
||||
int k = cast(int)(sqrt(269696.0));
|
||||
|
||||
// if root is odd -> make it even
|
||||
if (k % 2 == 1)
|
||||
k = k - 1;
|
||||
|
||||
// cycle through numbers
|
||||
while ((k * k) % 1000000 != 269696)
|
||||
k = k + 2;
|
||||
|
||||
// display output
|
||||
writefln("%d * %d = %d", k, k, k*k);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue