コラッツ・角谷の問題
Posted feedbacks - PostScript
PostScript版。ともかく走る、というだけです。2倍長演算部分、全く汎用性無し.... 219秒/Ghostscript 7.07/Intel Celeron 2GHz 169秒/Apple Preview 4.0/Intel X5365*2 3GHz 123秒/Adobe Acrobat Distiller (Win) 7.0 / Intel X5365 (Single Core 相当)
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | %!PS
/Loop 1024 1024 mul def % (2^10)^2 = 2^20 (2 20 exp cvi)
/TextOutput false def
/Limit 1024 1024 1024 mul mul 2 idiv def
/Limit2 Limit 2 idiv def
/F {
/N 0 def
{
dup 1 eq { exit } if
dup 2 mod 0 eq { 2 idiv } { 3 mul 1 add } ifelse
/N 1 N add def
} loop
pop
N
} def
/F2 {
0
exch
0
exch
{
dup 2 mod 0 eq {
exch
dup 2 mod 0 eq {
2 idiv
exch
2 idiv
} {
2 idiv
exch
2 idiv Limit2 add
} ifelse
} {
dup 1 eq { exch dup 0 eq { exit } if exch } if
3 mul 1 add
exch
3 mul
exch
{
dup Limit ge {
Limit sub
exch
1 add
exch
} {
exit
} ifelse
} loop
} ifelse
3 2 roll
1 add
3 1 roll
} loop
pop
pop
} def
/StartTime realtime def
/Max 0 def
/MaxNum 0 def
1 1 Loop {
dup F2 dup Max gt {
/Max exch def
/MaxNum exch def
} {pop pop} ifelse
} for
/FinishTime realtime def
save
TextOutput { /show { print } def /showpage {} def } if
/Times-Roman findfont 20 scalefont setfont
100 500 moveto (Max =) show
Max 10 string cvs show
100 400 moveto (MaxNum = ) show
MaxNum 10 string cvs show
100 300 moveto (Timer =) show
FinishTime StartTime sub 10 string cvs show
( ms) show
showpage
restore
|


ところてん
#4969()
Rating2/2=1.00
see: コラッツの問題の成り立つ範囲
[ reply ]