diff options
author | Jesse Luehrs <doy@tozt.net> | 2016-09-29 05:05:49 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2016-09-29 05:05:49 -0400 |
commit | 727dfe756a6725983c74e410f9c526db666cdad8 (patch) | |
tree | 889d2771f110ae08f58020f46dc2c1b0663c992c | |
parent | 170178579a93dbc8deaee328fefdb2f02c57df4f (diff) | |
download | projecteuler-727dfe756a6725983c74e410f9c526db666cdad8.tar.gz projecteuler-727dfe756a6725983c74e410f9c526db666cdad8.zip |
problem 206
-rw-r--r-- | 206.pl | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -0,0 +1,21 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.014; + +use bigint; + +for my $first (0..9) { + for my $second (0..9) { + my $min = 1020304050607080900 + $first * 100000000000000000 + $second * 1000000000000000; + my $max = 1020394959697989990 + $first * 100000000000000000 + $second * 1000000000000000; + my $guess = 10 + 10 * int(sqrt($min) / 10); + + while (1) { + my $square = $guess**2; + say $guess and exit if $square =~ /^1.2.3.4.5.6.7.8.9.0$/; + $guess += 10; + last if $square > $max; + } + } +} |