Thread Kleines mathe-skript (31 answers)
Opened by SirLant at 2003-09-02 16:39

Ishka
 2003-09-03 02:38
#83000 #83000
User since
2003-08-04
771 Artikel
HausmeisterIn
[Homepage] [default_avatar]
Effizient ist der code nicht - für größere Zahlen, mach das lieber so:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
my $sek=8*9/ggT(8,9);

print "Sie treffen sich nach $sek Sekunden wieder\n";

sub ggT
{
my ($flip,$flop)=@_;
($flip,$flop)=($flop,$flip) if $flip<$flop;
while(1)
{
$flip %= $flop;
($flip,$flop)=($flop,$flip) if $flip<$flop;
last if $flop==0;
}
return $flip;
}

edit:
Das Forum hat nen Bug mit '\n's\n\n

<!--EDIT|Ishka|1062542486-->
sub z{if(@_){1while$x[$k=rand 10];t($t=$x[$k]=1)}print map"$z[$x[$_]]$_".($_%3?
"":"\n"),1..9}sub t{$j=0;$x[$_+1]==$t&&($j+=2**$_)for 0..8;z,die"Gewinner $z[$t]
"if grep$_==($j&$_),7,56,73,84,146,273,292,448;z,die"Gleichstand\n"if@x>9&&!grep
!$_,@x}@x=4;@z=qw{. [ (};z$^T&1;while(<>){next if$_>9||$x[$_];t$t=$x[$_]=2;z 1}

View full thread Kleines mathe-skript