[seqfan] Re: More rows of triangle in A271100?
maybeso83 at gmail.com
Mon May 16 10:12:54 CEST 2016
Hello Felix et all,
I see that David added Pari code to the sequence. This week I jumped
into cloud sagemath and wrote a worksheet to generate rows. The
digraph structure does all the work - does Pari have something
similar? I don't know either one well enough to compare/combine them.
pr = prime_range(3600) # 7400 *determines how many rows get found.
wief = DiGraph([pr, lambda p, q: power_mod(p, q - 1, q^2) == 1])
sc = wief.all_simple_cycles() # could take a while!
maxn = 0
for c in sc: # reverse lexicographic
del c # duplicate
maxn = max(maxn, len(c))
# group by length
tbl = [[c for c in sc if len(c) == n] for n in range(maxn)]
n = 0
for t in tbl: # sort tuples by first element, get smallest
if len(t) > 0:
t.sort(key=lambda x: x)
print 'n=%s: %s'%(n, t)
n = n + 1
More information about the SeqFan