[seqfan] Re: More rows of triangle in A271100?

Bruce Leenstra 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.

Best Regards,
Bruce Leenstra

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!
sc.append([0, 0])
maxn = 0
for c in sc: # reverse lexicographic
    del c[0] # 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[0])
        print 'n=%s: %s'%(n, t[0])
    n = n + 1

More information about the SeqFan mailing list