-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- More optimizations in Number
inverse_sigma(n)
, by caching the div…
…isors `d` of `n` and the prime factors of each `d-1`. This leads to a big performance improvement. Example: # This now takes ~0.3 seconds (before it took ~4 seconds) say inverse_sigma(9325257382230393314439814176).len #=> 25 # This now takes ~3.7 seconds (before it took ~6.5 seconds) say inverse_sigma(13!).len #=> 53265 Also the duplicates are now removed. say inverse_sigma(7688) #=> [2800, 2928, 4575, 7687] Previously, 2800 was inlcuded twice in the returned array.
- Loading branch information
Showing
1 changed file
with
21 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters