Warum nicht so
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use strict;
use warnings;
my $x=123;
use constant LENGTH=>5;
use constant LOG10=>2.30258509299405;
$_ = $x;
if(s/.//){s/./0/g; s/^/1/;}
my $shorth= int(1.5+&Log() / LOG10);
my $shorth2=int(1.5+ log() / LOG10);
if($shorth != $shorth2) {die "logirithmical error";}
die "too long" if $shorth > LENGTH;
$x = 0 x (LENGTH-$shorth) . $x;
print "$x\n";
sub Log{
my($r)=@_ ? @_ : ($_);
if(abs($r)>=1){
return -&Log(1/$r);
}
$r-=1;
my $sign=1;
my $ret=0;
my $f=1;
for my $n (1..40){
$f*=$r;
$ret+=$sign*$f/$n;
$sign=-$sign;
}
return $ret;
}
Entschuldigt bitte, aber ich hatte halt etwas Langeweile\n\n
<!--EDIT|betterworld|1067044018-->