in reply to Finding sum of all digits from 1 to 1 million.
A slightly modified version:
#!/usr/bin/perl -w use strict; # or die :-) my $LIMIT = 1000000; my $s; foreach (1 .. $LIMIT) { foreach (/./g) { $s += $_; } } print "Sum: $s\n";
Golfers invited to make this even nicer (not to mention make it run faster...)
|
|---|