Thread Project Euler (56 answers)
Opened by Ronnie at 2007-12-15 12:19

Gast Gast
 2008-05-19 22:33
#109948 #109948
Hi!

Problem 16 habe ich so gelöst:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/perl -w
use strict;

my $zahl = `echo "2 ^ 1000" | bc`;
$zahl =~ s|\\||g;
$zahl =~ s|\n||g;
my @array = split(//, $zahl);
my $sum = 0;
foreach (@array){
        $sum += $_;
}
print $sum, "\n";


Wie geht das ohne bc bzw. wie ist es mit Perl möglich, als Ergebnis von "2 ** 1000" die gesamte Zahl zu bekommen und nicht nur 1.07150860718627e+301?

View full thread Project Euler