cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A182665 Greatest x < n such that n divides x*(x-1).

Original entry on oeis.org

0, 1, 1, 1, 1, 4, 1, 1, 1, 6, 1, 9, 1, 8, 10, 1, 1, 10, 1, 16, 15, 12, 1, 16, 1, 14, 1, 21, 1, 25, 1, 1, 22, 18, 21, 28, 1, 20, 27, 25, 1, 36, 1, 33, 36, 24, 1, 33, 1, 26, 34, 40, 1, 28, 45, 49, 39, 30, 1, 45, 1, 32, 36, 1, 40, 55, 1, 52, 46, 56, 1, 64, 1, 38, 51, 57, 56, 66, 1, 65, 1, 42, 1, 64, 51, 44, 58, 56, 1, 81, 78, 69, 63, 48, 76, 64, 1, 50, 55
Offset: 1

Views

Author

Robert Israel, Dec 23 2012

Keywords

Comments

a(n) = 1 iff n is in A246655. - Robert Israel, Jan 13 2015

Examples

			a(6) = 4 because 6 divides 4*3=12 but does not divide 5*4=20.
		

Crossrefs

Cf. A246655, A345992 [= gcd(a(n), n) = gcd(a(n), A344005(n))], A354919, A354920 (parity), A354921 (positions of odd terms), A354922 (of even terms).

Programs

  • Maple
    A:= proc(n)
           max(map(u -> u*modp(1/u,n/u),
                          map(t -> mul(s[1]^s[2],s = t),
                              combinat[powerset](ifactors(n)[2]))))
         end proc;
    seq(A(n),n=1..100);
  • Mathematica
    a[n_] := Module[{x}, Max[x /. {ToRules[Reduce[Mod[x*(x-1), n] == 0 && Mod[x*(x+1), n] != 0, x, Integers] /. C[] -> 0]}]]; a[1] = 0; a[2] = 1; Table[a[n], {n, 1, 100}] (* _Jean-François Alcover, Mar 04 2014 *)
  • PARI
    A182665(n) = forstep(x=n-1,0,-1,if(!((x*(x-1))%n),return(x))); \\ Antti Karttunen, Jun 12 2022
    
  • Python
    from itertools import combinations
    from math import prod
    from sympy import factorint
    from sympy.ntheory.modular import crt
    def A182665(n):
        if n == 1:
            return 0
        plist = tuple(p**q for p, q in factorint(n).items())
        return 1 if len(plist) == 1 else n-int(min(min(crt((m, n//m), (0, -1))[0], crt((n//m, m), (0, -1))[0]) for m in (prod(d) for l in range(1, len(plist)//2+1) for d in combinations(plist, l)))) # Chai Wah Wu, Jun 12 2022

Formula

a(n) = n - A344005(n). - Antti Karttunen, May 19 2022