-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalmost_divisors.sf
60 lines (49 loc) · 2.38 KB
/
almost_divisors.sf
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
#!/usr/bin/ruby
# Daniel "Trizen" Șuteu
# Date: 21 September 2018
# https://github.com/trizen
# Generate the almost divisors of a given integer.
func almost_divisors(n) {
var factors = n.factor
var common_divisors = Bag()
for p in factors, r in [-1, +1], d in divisors(p+r) {
common_divisors << d
}
var A = Set()
var factors_len = factors.len
for d,c in (common_divisors) {
A << Num(d) if (c >= factors_len)
}
return A.sort
}
#var n = 11934770651841535961
var n = 11611908222638446277
for d in (almost_divisors(n)) {
say "n / #{d} ≈ #{n/d}"
}
__END__
n / 1 ≈ 11611908222638446277
n / 2 ≈ 5805954111319223138.5
n / 3 ≈ 3870636074212815425.66666666666666666666666666666666666666666666667
n / 4 ≈ 2902977055659611569.25
n / 6 ≈ 1935318037106407712.83333333333333333333333333333333333333333333333
n / 9 ≈ 1290212024737605141.88888888888888888888888888888888888888888888889
n / 18 ≈ 645106012368802570.944444444444444444444444444444444444444444444444
n / 313 ≈ 37098748315138805.99680511182108626198083067092651757188498402556
n / 626 ≈ 18549374157569402.99840255591054313099041533546325878594249201278
n / 939 ≈ 12366249438379601.99893503727369542066027689030883919062832800852
n / 1878 ≈ 6183124719189800.99946751863684771033013844515441959531416400426
n / 2817 ≈ 4122083146126533.99964501242456514022009229676961306354277600284
n / 5634 ≈ 2061041573063266.99982250621228257011004614838480653177138800142
n / 427681 ≈ 27150862962437.99999766180868451018399227461589362164791047533
n / 855362 ≈ 13575431481218.99999883090434225509199613730794681082395523767
n / 1283043 ≈ 9050287654145.999999220602894836727997424871964540549303491777
n / 2566086 ≈ 4525143827072.99999961030144741836399871243598227027465174589
n / 3849129 ≈ 3016762551381.99999974020096494557599914162398818018310116393
n / 7698258 ≈ 1508381275690.99999987010048247278799957081199409009155058196
n / 133864153 ≈ 86743971125.999999992529740206102824256468421385372677030273
n / 267728306 ≈ 43371985562.99999999626487010305141212823421069268633851514
n / 401592459 ≈ 28914657041.99999999750991340203427475215614046179089234342
n / 803184918 ≈ 14457328520.99999999875495670101713737607807023089544617171
n / 1204777377 ≈ 9638219013.999999999169971134011424917385380153930297447808
n / 2409554754 ≈ 4819109506.9999999995849855670057124586926900769651487239