-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog.sf
99 lines (82 loc) · 2.73 KB
/
prog.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
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
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/ruby
# Primes p such that lcm(1,2,3,...,p-2,p-1,p) +/- 1 is prime.
# OEIS sequences:
# https://oeis.org/A154524
# https://oeis.org/A154525
func inflate_prime_power (p, k) {
if (k == 1) {
return "#{p.primorial}" if (p <= 5)
return "#{p}#"
}
return "#{p.primorial}^#{k}" if (p <= 5)
return "#{p}#^#{k}"
}
func display_deflated (p, r) {
var t = p.consecutive_lcm+r
var f = ((t - r) / p.primorial)
var u = f.primorial_deflation
assert_eq(p.primorial*f + r, t)
if ((u > 1) && u.is_int) {
return ("#{p}# * " + u.factor_map(inflate_prime_power).join(' * ') + (r.is_pos ? " + #{r}" : " - #{r.abs}"))
}
return ("#{p}# * #{f}" + (r.is_pos ? " + #{r}" : " - #{r.abs}"))
}
var pp1_smooth = [ 3, 5, 7, 19, 23, 29, 47, 61, 97, 181, 233, 307, 401, 887, 1021, 1087, 1361, 1481, 2053, 2293, 5407, 5857, 11059, 14281, 27277, 27803, 36497]
var pm1_smooth = [2, 3, 5, 7, 19, 31, 47, 89, 127, 139, 2251, 3271, 4253, 4373, 4549, 5449, 13331, 37123, 55291]
say "Prime p such that p+1 is smooth:"
for p in (pp1_smooth) {
say display_deflated(p, -1)
}
say "\nPrimes p such that p-1 is smooth:"
for p in (pm1_smooth) {
say display_deflated(p, +1)
}
__END__
Prime p such that p+1 is smooth:
3# * 1 - 1
5# * 2 - 1
7# * 2 - 1
19# * 2^2 * 6 - 1
23# * 2^2 * 6 - 1
29# * 2 * 6 * 30 - 1
47# * 2^2 * 6 * 30 - 1
61# * 2^2 * 6 * 7# - 1
97# * 2^2 * 6^2 * 7# - 1
181# * 2^3 * 6 * 30 * 13# - 1
233# * 2^3 * 6 * 30 * 13# - 1
307# * 2^3 * 6^2 * 30 * 17# - 1
401# * 2^3 * 6^2 * 7# * 19# - 1
887# * 2^3 * 6^2 * 30 * 7# * 29# - 1
1021# * 2^3 * 6^2 * 30 * 7# * 31# - 1
1087# * 2^4 * 6^2 * 30 * 7# * 31# - 1
1361# * 2^4 * 6^2 * 30 * 11# * 31# - 1
1481# * 2^4 * 6^2 * 30 * 11# * 37# - 1
2053# * 2^5 * 6^2 * 30 * 11# * 43# - 1
2293# * 2^4 * 6^3 * 30 * 13# * 47# - 1
5407# * 2^5 * 6^2 * 30 * 7# * 17# * 73# - 1
5857# * 2^5 * 6^2 * 30 * 7# * 17# * 73# - 1
11059# * 2^5 * 6^3 * 30 * 7# * 19# * 103# - 1
14281# * 2^5 * 6^3 * 30 * 7# * 23# * 113# - 1
27277# * 2^5 * 6^3 * 30 * 7# * 11# * 29# * 163# - 1
27803# * 2^5 * 6^3 * 30 * 7# * 11# * 29# * 163# - 1
36497# * 2^6 * 6^3 * 30 * 7# * 13# * 31# * 191# - 1
Primes p such that p-1 is smooth:
2# * 1 + 1
3# * 1 + 1
5# * 2 + 1
7# * 2 + 1
19# * 2^2 * 6 + 1
31# * 2 * 6 * 30 + 1
47# * 2^2 * 6 * 30 + 1
89# * 2^2 * 6^2 * 7# + 1
127# * 2^2 * 6 * 30 * 11# + 1
139# * 2^3 * 6 * 30 * 11# + 1
2251# * 2^4 * 6^3 * 30 * 13# * 47# + 1
3271# * 2^4 * 6^2 * 30 * 7# * 13# * 53# + 1
4253# * 2^5 * 6^2 * 30 * 7# * 13# * 61# + 1
4373# * 2^5 * 6^2 * 30 * 7# * 13# * 61# + 1
4549# * 2^5 * 6^2 * 30 * 7# * 13# * 67# + 1
5449# * 2^5 * 6^2 * 30 * 7# * 17# * 73# + 1
13331# * 2^5 * 6^3 * 30 * 7# * 23# * 113# + 1
37123# * 2^6 * 6^3 * 30 * 7# * 13# * 31# * 191# + 1
55291# * 2^6 * 6^3 * 30 * 7# * 13# * 37# * 233# + 1