Leser: 4
8 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use strict;
for (0..10) {
printf "%04d\n",$_;
}
_ _ END _ _
0000
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
($a="00".$a) =~ s/.*(..)/$1/
$a=substr("00".$a, -2, 2);
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;
}
8 Einträge, 1 Seite |