home *** CD-ROM | disk | FTP | other *** search
- `
- The prime factors of n!
-
- n! = p(1)**j(1) p(2)**j(2) p(3)**j(3) ...
-
- can be calculated by the following algorithm, where "/" is
- an integer divide with the remainder discarded. To find the
- power j of some prime p in n!, calculate the sum
-
- j = n/p + n/p**2 + n/p**3 + ...
-
- using the recursion relation
-
- n/p**(i+1) = (n/p**i)/p
-
- (In the ACT program, "a" is the current term in the j sum.)
- `
-
- @{ns|prime factors of n!|{
- @{ns|n|@{rs|Type an integer less than 600. }}
- @{ge|@@{n}|50|{@{ps|This may take a minute or two.|}}}
- @{dd|answer}
- @{cr|primes}@{prime loop}
- @{ps||@@{n}! =@@{answer}||}
- @{prime factors of n!}
- }}
-
- @{ns|prime loop|{
- @{ns|p|@@{in|primes| }}
- @{ns|a|@@{dv|@@{n}|@@{p}}}
- @{ge|@@{a}|1|{
- @{ns|j|0}@{calc j}
- @{ns|answer|@@{answer} @@{p}@@{ge|@@{j}|2|**@@{j}}}
- @{prime loop}
- }}
- }}
-
- @{ns|calc j|{
- @{ns|j|@@{ad|@@{j}|@@{a}}}
- @{ns|a|@@{dv|@@{a}|@@{p}}}
- @{ge|@@{a}|1|{
- @{calc j}
- }}
- }}
-
- @{ns|primes|{
- 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71
- 73 79 83 89 97 101 103 107 109 113 127 131 127 131 137 139 149
- 151 157 163 167 173 179 181 191 193 197 199 211
- 223 227 229 233 239 241 251 257 263 269 271
- 277 281 283 293 307 311 313 317 331 337 347 349
- 353 359 367 373 379 383 389 397 401 409 419
- 421 431 433 439 443 449 457 461 463 467 479 487
- 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593
- 599
- }}
-
- @{prime factors of n!}
-