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.

Showing 1-2 of 2 results.

A069869 Largest prime that is a concatenation of the parts of a partition of n, or 0 if no such prime exists.

Original entry on oeis.org

0, 11, 3, 211, 2111, 0, 112111, 1111211, 0, 11131111, 1121111111, 0, 111211111111, 2111111111111, 0, 31111111111111, 212111111111111, 0, 1111111111111111111, 2111111111111111111, 0, 111111111111111121111, 11111111111111111111111, 0, 211111111111111111111111
Offset: 1

Views

Author

Amarnath Murthy, Apr 21 2002

Keywords

Comments

Conjecture: a(n) = 0 only for n = 1 or n = 3k with k>1.

Examples

			a(4) = 211 as the partitions of 4 are (4), (3,1), (2,2), (2,1,1) (1,1,1,1). The primes that can be formed are 13, 31, 211 and 211 is the largest prime using a partition.
		

Crossrefs

Programs

  • Maple
    with(combinat):
    a:= proc(n) local k, w;
          if n=1 or n>3 and irem(n, 3)=0 then return 0 fi;
          for k from 0 do w:= max(select(isprime,
            map(x-> parse(cat(x[])), [seq(permute(i)[],
              i=map(x->[x[], 1$(n-k)], partition(k)))]))[]);
            if w>0 then return w fi
          od
        end:
    seq(a(n), n=1..30);  # Alois P. Heinz, May 25 2013
  • Mathematica
    f[n_] := If[ PrimeQ@n, n, If[n > 5 && Mod[n, 3] == 0, 0, Block[{len = PartitionsP[n], p = IntegerPartitions[n], t = {}}, Do[ AppendTo[t, Select[FromDigits /@ Join @@@ IntegerDigits /@ Permutations@p[[i]], PrimeQ@# &]], {i, len}]; t = Union@Flatten@t; If[Length@t > 0, Max@t, 0]] ]]; Array[f, 29]
  • Python
    from collections import Counter
    from operator import itemgetter
    from sympy.utilities.iterables import partitions, multiset_permutations
    from sympy import isprime
    def A069869(n):
        smax, m = 0, 0
        if n==3 or n%3:
            for s, p in sorted(partitions(n,size=True),key=itemgetter(0),reverse=True):
                if s0:
                    smax=s
        return m # Chai Wah Wu, Feb 21 2024

Extensions

More terms from David Wasserman, Apr 30 2003
a(8) corrected and a(16)-a(24) added by Robert G. Wilson v, Feb 06 2006
a(25) from Alois P. Heinz, May 25 2013

A116381 Number of compositions of n which are prime when concatenated and read as a decimal string.

Original entry on oeis.org

0, 2, 1, 3, 7, 0, 29, 27, 0, 90, 236, 0, 758, 1039, 0, 3949, 9325, 0, 32907, 51243, 0, 184458, 426372, 0, 1552101, 2537233, 0, 9526385, 21117111, 0, 78112040, 134568638, 0, 505079269, 1096046406, 0
Offset: 1

Views

Author

Robert G. Wilson v, Feb 06 2006

Keywords

Examples

			The eight compositions of 4 are 4,13,31,22,112,121,211,1111 of which 3 {13,31,211} are primes.
Primes for n=11 are: 11, 29, 47, 83, 101, 137, 173, 191, 227, 263, 281, 317, 353, 443, 461, 641, 821, 911, 1163, 1181, ..., 131111111, 212111111, 1111111121, 1111211111, 1121111111.
		

Crossrefs

Cf. A069869, A069870; not the same as A073901.

Programs

  • Mathematica
    f[n_] := If[n > 5 && Mod[n, 3] == 0, 0, Block[{len = PartitionsP@ n, p = IntegerPartitions[n], c = 0}, Do[c = c + Length@ Select[ FromDigits /@ Join @@@ IntegerDigits /@ Permutations@ p[[i]], PrimeQ@# &], {i, len}]; c]]; Array[f, 28] (* Robert G. Wilson v, Aug 03 2012 *)
  • Python
    from sympy import isprime
    from sympy.utilities.iterables import partitions, multiset_permutations
    def a(n):
        c = 0
        for p in partitions(n):
            plst = [k for k in p for _ in range(p[k])]
            s = sum(sum(map(int, str(pi))) for pi in plst)
            if s != 3 and s%3 == 0: continue
            for m in multiset_permutations(plst):
                if isprime(int("".join(map(str, m)))):
                    c += 1
        return c
    print([a(n) for n in range(1, 22)]) # Michael S. Branicky, Nov 19 2022
    
  • Python
    from collections import Counter
    from sympy.utilities.iterables import partitions, multiset_permutations
    from sympy import isprime
    def A116381(n): return sum(1 for p in partitions(n) for a in multiset_permutations(Counter(p).elements()) if isprime(int(''.join(str(d) for d in a)))) if n==3 or n%3 else 0 # Chai Wah Wu, Feb 21 2024

Extensions

a(29)-a(33) from Michael S. Branicky, Nov 19 2022
a(34)-a(36) from Michael S. Branicky, Jul 10 2023
Showing 1-2 of 2 results.