in reply to Vampire Numbers Revisited
Take a number such as 2025. Break it in half to give 20 and 25. Add the numbers together and find that the result is the square root of the original number. The challenge is to find the six digit number that fits the criteria. Note that 998001 is considered 'cheating' because of the leading zeroes on 001
My solution as follows:
#! /usr/bin/perl -w use strict; use warnings; foreach my $first (100..999) { foreach my $second (100..999) { if (($first + $second)**2 == $first . $second) { print "$first + $second = ", $first + $second, " (", $first . $ +second, ")\n"; } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Vampire Numbers Revisited
by Roy Johnson (Monsignor) on Mar 23, 2005 at 23:55 UTC | |
Re^2: Vampire Numbers Revisited
by tilly (Archbishop) on Mar 25, 2005 at 02:38 UTC |