line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2010, 2011, 2012, 2013, 2014 Kevin Ryde |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This file is part of Math-NumSeq. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Math-NumSeq is free software; you can redistribute it and/or modify |
6
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by the |
7
|
|
|
|
|
|
|
# Free Software Foundation; either version 3, or (at your option) any later |
8
|
|
|
|
|
|
|
# version. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Math-NumSeq is distributed in the hope that it will be useful, but |
11
|
|
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
12
|
|
|
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
13
|
|
|
|
|
|
|
# for more details. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along |
16
|
|
|
|
|
|
|
# with Math-NumSeq. If not, see . |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# http://www.luschny.de/math/factorial/approx/SimpleCases.html |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Math::NumSeq::Factorials; |
24
|
2
|
|
|
2
|
|
8307
|
use 5.004; |
|
2
|
|
|
|
|
6
|
|
25
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
41
|
|
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
6
|
use vars '$VERSION','@ISA'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
111
|
|
28
|
|
|
|
|
|
|
$VERSION = 72; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
|
381
|
use Math::NumSeq; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
70
|
|
31
|
|
|
|
|
|
|
@ISA = ('Math::NumSeq'); |
32
|
|
|
|
|
|
|
*_is_infinite = \&Math::NumSeq::_is_infinite; |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
2
|
|
339
|
use Math::NumSeq::Fibonacci; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
73
|
|
35
|
|
|
|
|
|
|
*_blog2_estimate = \&Math::NumSeq::Fibonacci::_blog2_estimate; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
38
|
|
|
|
|
|
|
#use Smart::Comments; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# use constant name => Math::NumSeq::__('Factorials'); |
42
|
2
|
|
|
2
|
|
9
|
use constant description => Math::NumSeq::__('The factorials 1, 2, 6, 24, 120, etc, 1*2*...*N.'); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
6
|
|
43
|
2
|
|
|
2
|
|
6
|
use constant values_min => 1; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
70
|
|
44
|
2
|
|
|
2
|
|
7
|
use constant i_start => 0; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
64
|
|
45
|
2
|
|
|
2
|
|
7
|
use constant characteristic_increasing => 1; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
64
|
|
46
|
2
|
|
|
2
|
|
7
|
use constant characteristic_integer => 1; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
76
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
49
|
|
|
|
|
|
|
# cf A006882 double a(n)=n*a(n-2), n*(n-2)*(n-4)*...*3*1 or *4*2 |
50
|
|
|
|
|
|
|
# A001147 double factorial 1*3*5*...*(2n-1) odd numbers, bisection |
51
|
|
|
|
|
|
|
# A000165 double factorial 2*4*6*...*2n even numbers, bisection |
52
|
|
|
|
|
|
|
# |
53
|
|
|
|
|
|
|
# A007661 triple a(n)=n*a(n-3) |
54
|
|
|
|
|
|
|
# A007662 quadruple a(n)=n*a(n-4) |
55
|
|
|
|
|
|
|
# A047053 quad 4^n*n! quad on multiples of 4 |
56
|
|
|
|
|
|
|
# A007696 quad n=4k+1 products |
57
|
|
|
|
|
|
|
# A001813 quad (2*n)!/n! |
58
|
|
|
|
|
|
|
# A008545 quad n=4k+1 products |
59
|
|
|
|
|
|
|
# A080500 squares n*(n-1)*(n-4)*(n-9)*(n-16)*(n-25)*...*1 |
60
|
|
|
|
|
|
|
# |
61
|
|
|
|
|
|
|
# A001013 Jordan-Polya products of factorials |
62
|
|
|
|
|
|
|
# |
63
|
|
|
|
|
|
|
# A008906 n! num digits excl trailing zeros |
64
|
|
|
|
|
|
|
# A027868 n! num trailing zeros, is power of 5 |
65
|
|
|
|
|
|
|
# A000966 n! never ends these 0s |
66
|
|
|
|
|
|
|
# |
67
|
|
|
|
|
|
|
# A008904 n! low non-zero |
68
|
|
|
|
|
|
|
# A136690 base 3 |
69
|
|
|
|
|
|
|
# A136691 base 4 |
70
|
|
|
|
|
|
|
# A136692 base 5 |
71
|
|
|
|
|
|
|
# A136693 base 6 |
72
|
|
|
|
|
|
|
# A136694 base 7 |
73
|
|
|
|
|
|
|
# A136695 base 8 |
74
|
|
|
|
|
|
|
# A136696 base 9 |
75
|
|
|
|
|
|
|
# A136697 base 11 |
76
|
|
|
|
|
|
|
# A136698 base 12 |
77
|
|
|
|
|
|
|
# A136699 base 13 |
78
|
|
|
|
|
|
|
# A136700 base 14 |
79
|
|
|
|
|
|
|
# A136701 base 15 |
80
|
|
|
|
|
|
|
# A136702 base 16 |
81
|
|
|
|
|
|
|
# |
82
|
|
|
|
|
|
|
# A008905 n! leading digit |
83
|
|
|
|
|
|
|
# A136754 base 3 |
84
|
|
|
|
|
|
|
# A136755 base 4 |
85
|
|
|
|
|
|
|
# A136756 base 5 |
86
|
|
|
|
|
|
|
# A136757 base 6 |
87
|
|
|
|
|
|
|
# A136758 base 7 |
88
|
|
|
|
|
|
|
# A136759 base 8 |
89
|
|
|
|
|
|
|
# A136760 base 9 |
90
|
|
|
|
|
|
|
# A136761 base 11 |
91
|
|
|
|
|
|
|
# A136762 base 12 |
92
|
|
|
|
|
|
|
# A136763 base 13 |
93
|
|
|
|
|
|
|
# A136764 base 14 |
94
|
|
|
|
|
|
|
# A136765 base 15 |
95
|
|
|
|
|
|
|
# A136766 base 16 |
96
|
|
|
|
|
|
|
|
97
|
2
|
|
|
2
|
|
7
|
use constant oeis_anum => 'A000142'; # factorials 1,1,2,6,24, including 0!==1 |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
784
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
2
|
|
|
2
|
|
8
|
use constant 1.02; # for leading underscore |
|
2
|
|
|
|
|
24
|
|
|
2
|
|
|
|
|
126
|
|
103
|
2
|
|
|
|
|
3
|
use constant _UV_I_LIMIT => do { |
104
|
2
|
|
|
|
|
2
|
my $u = ~0 >> 1; |
105
|
2
|
|
|
|
|
2
|
my $limit = 1; |
106
|
2
|
|
|
|
|
3
|
my $i = 2; |
107
|
2
|
|
|
|
|
5
|
for (; $i++; ) { |
108
|
38
|
100
|
|
|
|
44
|
if ($u < $i) { |
109
|
|
|
|
|
|
|
### _UV_LIMIT stop before: "i=$i" |
110
|
2
|
|
|
|
|
5
|
last; |
111
|
|
|
|
|
|
|
} |
112
|
36
|
|
|
|
|
21
|
$u -= ($u % $i); |
113
|
36
|
|
|
|
|
24
|
$u /= $i; |
114
|
36
|
|
|
|
|
39
|
$limit *= $i; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
### $limit |
117
|
|
|
|
|
|
|
### $i |
118
|
2
|
|
|
|
|
202
|
$i |
119
|
2
|
|
|
2
|
|
6
|
}; |
|
2
|
|
|
|
|
4
|
|
120
|
|
|
|
|
|
|
### _UV_I_LIMIT: _UV_I_LIMIT() |
121
|
|
|
|
|
|
|
|
122
|
2
|
|
|
|
|
2
|
use constant _NV_LIMIT => do { |
123
|
2
|
|
|
|
|
3
|
my $f = 1.0; |
124
|
2
|
|
|
|
|
2
|
my $max; |
125
|
2
|
|
|
|
|
2
|
for (;;) { |
126
|
104
|
|
|
|
|
66
|
$max = $f; |
127
|
104
|
|
|
|
|
62
|
my $l = 2.0*$f; |
128
|
104
|
|
|
|
|
65
|
my $h = 2.0*$f+2.0; |
129
|
104
|
|
|
|
|
57
|
$f = 2.0*$f + 1.0; |
130
|
104
|
|
|
|
|
96
|
$f = sprintf '%.0f', $f; |
131
|
104
|
100
|
66
|
|
|
253
|
last unless ($f < $h && $f > $l); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
### uv : ~0 |
134
|
|
|
|
|
|
|
### 53 : 1<<53 |
135
|
|
|
|
|
|
|
### $max |
136
|
2
|
|
|
|
|
1138
|
$max |
137
|
2
|
|
|
2
|
|
7
|
}; |
|
2
|
|
|
|
|
2
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub rewind { |
142
|
7
|
|
|
7
|
1
|
415
|
my ($self) = @_; |
143
|
|
|
|
|
|
|
### Factorials rewind() |
144
|
7
|
|
|
|
|
29
|
$self->{'i'} = $self->i_start; |
145
|
7
|
|
|
|
|
12
|
$self->{'f'} = 1; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
sub seek_to_i { |
148
|
20
|
|
|
20
|
1
|
388
|
my ($self, $i) = @_; |
149
|
20
|
|
|
|
|
15
|
$self->{'i'} = $i; |
150
|
20
|
|
|
|
|
29
|
$self->{'f'} = $self->ith($i-1); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
sub _UNTESTED__seek_to_value { |
153
|
0
|
|
|
0
|
|
0
|
my ($self, $value) = @_; |
154
|
0
|
|
|
|
|
0
|
my $i = $self->{'i'} = $self->value_to_i_ceil($value); |
155
|
0
|
|
|
|
|
0
|
$self->{'f'} = $self->ith($i); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
sub next { |
158
|
55
|
|
|
55
|
1
|
889
|
my ($self) = @_; |
159
|
|
|
|
|
|
|
### Factorials next() ... |
160
|
|
|
|
|
|
|
|
161
|
55
|
|
|
|
|
44
|
my $i = $self->{'i'}++; |
162
|
55
|
50
|
|
|
|
75
|
if ($i == _UV_I_LIMIT) { |
163
|
0
|
|
|
|
|
0
|
$self->{'f'} = Math::NumSeq::_to_bigint($self->{'f'}); |
164
|
|
|
|
|
|
|
} |
165
|
55
|
|
100
|
|
|
100
|
return ($i, $self->{'f'} *= ($i||1)); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub ith { |
169
|
57
|
|
|
57
|
1
|
733
|
my ($self, $i) = @_; |
170
|
|
|
|
|
|
|
### Factorials ith() ... |
171
|
|
|
|
|
|
|
|
172
|
57
|
50
|
|
|
|
75
|
if (_is_infinite($i)) { |
173
|
0
|
|
|
|
|
0
|
return $i; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
57
|
100
|
66
|
|
|
166
|
if (! ref $i && $i >= _UV_I_LIMIT) { |
177
|
|
|
|
|
|
|
# Plain index $i automatically use Math::BigInt when UV limit reached. |
178
|
|
|
|
|
|
|
# Maybe should check if BigInt new enough to have bfac(), circa vers 1.60 |
179
|
3
|
|
|
|
|
15
|
return Math::NumSeq::_bigint()->bfac($i); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
54
|
|
|
|
|
41
|
my $value = ($i*0) + 1; # inherit bignum 1 |
183
|
54
|
|
|
|
|
74
|
while ($i >= 2) { |
184
|
168
|
|
|
|
|
102
|
$value *= $i; |
185
|
168
|
|
|
|
|
182
|
$i -= 1; |
186
|
|
|
|
|
|
|
} |
187
|
54
|
|
|
|
|
72
|
return $value; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub pred { |
191
|
1463
|
|
|
1463
|
1
|
3487
|
my ($self, $value) = @_; |
192
|
1463
|
|
|
|
|
1222
|
return defined($self->value_to_i($value)); |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
sub value_to_i { |
195
|
1495
|
|
|
1495
|
1
|
1031
|
my ($self, $value) = @_; |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# NV inf or nan gets $value%$i=nan and nan==0 is false, |
198
|
|
|
|
|
|
|
# but Math::BigInt binf()%$i=0 so would go into infinite loop |
199
|
|
|
|
|
|
|
# hence explicit check against _is_infinite() |
200
|
|
|
|
|
|
|
# |
201
|
1495
|
50
|
|
|
|
1664
|
if (_is_infinite($value)) { |
202
|
0
|
|
|
|
|
0
|
return undef; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
1495
|
100
|
|
|
|
3464
|
if ($value == 1) { |
206
|
8
|
|
|
|
|
121
|
return 0; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
1487
|
|
|
|
|
1295
|
my $i = 1; |
210
|
1487
|
|
|
|
|
805
|
for (;;) { |
211
|
2589
|
100
|
|
|
|
3946
|
if ($value <= 1) { |
212
|
31
|
100
|
|
|
|
343
|
return ($value == 1 ? $i : undef); |
213
|
|
|
|
|
|
|
} |
214
|
2558
|
|
|
|
|
2219
|
$i++; |
215
|
2558
|
100
|
|
|
|
2433
|
if (($value % $i) == 0) { |
216
|
1102
|
|
|
|
|
3494
|
$value /= $i; |
217
|
|
|
|
|
|
|
} else { |
218
|
1456
|
|
|
|
|
3542
|
return undef; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
} |
221
|
0
|
|
|
|
|
0
|
return $i; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub value_to_i_floor { |
225
|
52
|
|
|
52
|
1
|
114
|
my ($self, $value) = @_; |
226
|
52
|
50
|
|
|
|
75
|
if (_is_infinite($value)) { |
227
|
0
|
|
|
|
|
0
|
return $value; |
228
|
|
|
|
|
|
|
} |
229
|
52
|
100
|
|
|
|
1518
|
if ($value < 2) { |
230
|
14
|
|
|
|
|
138
|
return $self->i_start; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# "/" operator converts 64-bit UV to an NV and so loses bits, making the |
234
|
|
|
|
|
|
|
# result come out 1 too small sometimes. Experimental switch to BigInt to |
235
|
|
|
|
|
|
|
# keep precision. ENHANCE-ME: Maybe better _divrem(). |
236
|
|
|
|
|
|
|
# |
237
|
38
|
50
|
66
|
|
|
361
|
if (! ref $value && $value > _NV_LIMIT) { |
238
|
0
|
|
|
|
|
0
|
$value = Math::NumSeq::_to_bigint($value); |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
38
|
|
|
|
|
31
|
my $i = 2; |
242
|
38
|
|
|
|
|
29
|
for (;; $i++) { |
243
|
|
|
|
|
|
|
### $value |
244
|
|
|
|
|
|
|
### $i |
245
|
|
|
|
|
|
|
|
246
|
137
|
100
|
|
|
|
1548
|
if ($value < $i) { |
247
|
38
|
|
|
|
|
369
|
return $i-1; |
248
|
|
|
|
|
|
|
} |
249
|
99
|
|
|
|
|
940
|
$value = int($value/$i); |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
# ENHANCE-ME: should be able to notice rounding in $value/$i divisions of |
254
|
|
|
|
|
|
|
# value_to_i_floor(), rather than multiplying back. |
255
|
|
|
|
|
|
|
# |
256
|
|
|
|
|
|
|
sub _UNTESTED__value_to_i_ceil { |
257
|
0
|
|
|
0
|
|
0
|
my ($self, $value) = @_; |
258
|
0
|
0
|
|
|
|
0
|
if ($value < 0) { return 0; } |
|
0
|
|
|
|
|
0
|
|
259
|
0
|
|
|
|
|
0
|
my $i = $self->value_to_i_floor($value); |
260
|
0
|
0
|
|
|
|
0
|
if ($self->ith($i) < $value) { |
261
|
0
|
|
|
|
|
0
|
$i += 1; |
262
|
|
|
|
|
|
|
} |
263
|
0
|
|
|
|
|
0
|
return $i; |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
#-------- |
268
|
|
|
|
|
|
|
# Stirling |
269
|
|
|
|
|
|
|
# n! ~= sqrt(2pi*n) * binomial(n,e)^n |
270
|
|
|
|
|
|
|
# n! ~= sqrt(2*Pi) * n^(n+1/2) / e^n |
271
|
|
|
|
|
|
|
# log(i!) ~= i*log(i) - i |
272
|
|
|
|
|
|
|
# |
273
|
|
|
|
|
|
|
# f(x) = x*log(x) - x - t |
274
|
|
|
|
|
|
|
# f'(x) = log(x) |
275
|
|
|
|
|
|
|
# sub = f(x) / f'(x) |
276
|
|
|
|
|
|
|
# = (x*log(x) - x - t) / log(x) |
277
|
|
|
|
|
|
|
# = x - (x+t)/log(x) |
278
|
|
|
|
|
|
|
# new = x - sub |
279
|
|
|
|
|
|
|
# = x - (x - (x+t)/log(x)) |
280
|
|
|
|
|
|
|
# = (x+t)/log(x) |
281
|
|
|
|
|
|
|
# |
282
|
|
|
|
|
|
|
# start x=t |
283
|
|
|
|
|
|
|
# new1 = 2t/log(t) |
284
|
|
|
|
|
|
|
# new2 = (2t/log(t) + t) / log(2t/log(t)) |
285
|
|
|
|
|
|
|
# = (2t/log(t) + t) / (log(2t) - log(log(t))) |
286
|
|
|
|
|
|
|
# |
287
|
|
|
|
|
|
|
# log2(i!) = log(i!)/log(2) |
288
|
|
|
|
|
|
|
# ~= (i*log(i) - i)/log(2) |
289
|
|
|
|
|
|
|
# log2(i!)*log(2) ~= i*log(i) - i |
290
|
|
|
|
|
|
|
# |
291
|
|
|
|
|
|
|
#-------- |
292
|
|
|
|
|
|
|
# Gosper, approximating terms of Stirling series |
293
|
|
|
|
|
|
|
# |
294
|
|
|
|
|
|
|
# n! ~= sqrt((2n+1/3)pi) * n^n * e^-n |
295
|
|
|
|
|
|
|
# |
296
|
|
|
|
|
|
|
sub value_to_i_estimate { |
297
|
16
|
|
|
16
|
1
|
225
|
my ($self, $value) = @_; |
298
|
|
|
|
|
|
|
### value_to_i_estimate: $value |
299
|
|
|
|
|
|
|
|
300
|
16
|
100
|
|
|
|
18
|
if ($value <= 1) { |
301
|
10
|
|
|
|
|
10
|
return 0; |
302
|
|
|
|
|
|
|
} |
303
|
6
|
50
|
|
|
|
73
|
if ($value <= 3) { |
304
|
0
|
|
|
|
|
0
|
return 1; |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
|
307
|
6
|
|
|
|
|
73
|
my $t; |
308
|
6
|
100
|
|
|
|
15
|
if (defined (my $blog2 = _blog2_estimate($value))) { |
309
|
1
|
|
|
|
|
219
|
$t = $blog2 * log(2); |
310
|
|
|
|
|
|
|
} else { |
311
|
5
|
|
|
|
|
6
|
$t = log($value); |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
# two steps of Newton's method |
315
|
6
|
|
|
|
|
10
|
my $x = 2*$t/log($t); |
316
|
6
|
|
|
|
|
9
|
return int(($x+$t)/log($x)); |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
# # single step of Newton's method starting x=t |
320
|
|
|
|
|
|
|
# # x-1 is a touch under the true i, so just int() down |
321
|
|
|
|
|
|
|
# return int(2*$t/log($t)); |
322
|
|
|
|
|
|
|
# |
323
|
|
|
|
|
|
|
# multiple steps |
324
|
|
|
|
|
|
|
# my $x = $t; |
325
|
|
|
|
|
|
|
# for (1 .. 10) { |
326
|
|
|
|
|
|
|
# ### $x |
327
|
|
|
|
|
|
|
# ### log: log($x) |
328
|
|
|
|
|
|
|
# ### f: ($x*log($x)-$x - $t) |
329
|
|
|
|
|
|
|
# ### fd: log($x) |
330
|
|
|
|
|
|
|
# ### sub: ($x*log($x) - $x - $t)/log($x) |
331
|
|
|
|
|
|
|
# ### new: ($x+$t)/log($x) |
332
|
|
|
|
|
|
|
# |
333
|
|
|
|
|
|
|
# $x = ($x+$t)/log($x); |
334
|
|
|
|
|
|
|
# } |
335
|
|
|
|
|
|
|
# return int($x)-1; |
336
|
|
|
|
|
|
|
} |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
1; |
339
|
|
|
|
|
|
|
__END__ |