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.

A361530 Primes that can be written as the result of shuffling the decimal digits of two primes.

This page as a plain text file.
%I A361530 #11 Apr 16 2023 09:48:04
%S A361530 23,37,53,73,113,127,131,137,139,151,157,173,179,193,197,211,223,229,
%T A361530 233,239,241,271,283,293,311,313,317,331,337,347,353,359,367,373,379,
%U A361530 383,389,397,421,431,433,457,523,541,547,571,593,613,617,631,673,677,719
%N A361530 Primes that can be written as the result of shuffling the decimal digits of two primes.
%C A361530 Each term is essentially an element of the shuffle product of the decimal digits of two primes (possibly equal).
%H A361530 Michael S. Branicky, <a href="/A361530/b361530.txt">Table of n, a(n) for n = 1..10000</a>
%H A361530 John D. Cook, <a href="https://www.johndcook.com/blog/2023/03/13/shuffle-product/">Shuffle product</a>.
%H A361530 Wikipedia, <a href="https://en.wikipedia.org/wiki/Shuffle_algebra#Shuffle_product">Shuffle product</a>.
%e A361530 37 and 73 are in the sequence because they are both the result of shuffling 3 and 7.
%e A361530 127 is in the sequence because it is the result of shuffling 2 and the digits of 17.
%e A361530 1193 is in the sequence because it is the result of shuffling the digits of 13 and the digits of 19.
%e A361530 163 is not in the sequence because it is not the result of shuffling the digits of two primes. 163 is the result of permuting the digits of 3 and 61; however, 163 contains the digits of 61 in the wrong order.
%o A361530 (Python)
%o A361530 import sympy
%o A361530 def get_shuffle_product(list_1, list_2):
%o A361530     shuffle_product = set()
%o A361530     shuffle = []
%o A361530     _get_shuffle_product(list_1, list_2, shuffle, shuffle_product)
%o A361530     return shuffle_product
%o A361530 def _get_shuffle_product(list_1, list_2, shuffle, shuffle_product):
%o A361530     if len(list_1) == 0 and len(list_2) == 0:
%o A361530         shuffle_product.add(tuple(shuffle))
%o A361530         return
%o A361530     else:
%o A361530         if len(list_1) == 0:
%o A361530             shuffle.append(list_2[0])
%o A361530             _get_shuffle_product(list_1, list_2[1:], shuffle, shuffle_product)
%o A361530             shuffle.pop()
%o A361530         elif len(list_2) == 0:
%o A361530             shuffle.append(list_1[0])
%o A361530             _get_shuffle_product(list_1[1:], list_2, shuffle, shuffle_product)
%o A361530             shuffle.pop()
%o A361530         else:
%o A361530             shuffle.append(list_1[0])
%o A361530             _get_shuffle_product(list_1[1:], list_2, shuffle, shuffle_product)
%o A361530             shuffle.pop()
%o A361530             shuffle.append(list_2[0])
%o A361530             _get_shuffle_product(list_1, list_2[1:], shuffle, shuffle_product)
%o A361530             shuffle.pop()
%o A361530 max_prime_index = 25 # one and two digit primes.
%o A361530 max_element = 999
%o A361530 prime_set = set()
%o A361530 for p_index in range(1, max_prime_index+1):
%o A361530     p = sympy.prime(p_index)
%o A361530     for q_index in range(p_index, max_prime_index+1):
%o A361530         q = sympy.prime(q_index)
%o A361530         list_p = list(str(p))
%o A361530         list_q = list(str(q))
%o A361530         shuffle_product = get_shuffle_product(list_p, list_q)
%o A361530         for s in shuffle_product:
%o A361530             candidate = int(''.join(s))
%o A361530             if sympy.isprime(candidate) and candidate <= max_element:
%o A361530                 prime_set.add(candidate)
%o A361530 print(sorted(prime_set))
%o A361530 (Python)
%o A361530 from sympy import isprime
%o A361530 from itertools import chain, combinations
%o A361530 def powerset(s): # skipping empty set and entire set
%o A361530     return chain.from_iterable(combinations(s, r) for r in range(1, len(s)))
%o A361530 def ok(n):
%o A361530     if not isprime(n): return False
%o A361530     s = str(n)
%o A361530     for indices in powerset(range(len(s))):
%o A361530         t1 = "".join(s[i] for i in indices)
%o A361530         t2 = "".join(s[i] for i in range(len(s)) if i not in indices)
%o A361530         if t1[0] != "0" and t2[0] != "0" and isprime(int(t1)) and isprime(int(t2)):
%o A361530             return True
%o A361530 print([k for k in range(720) if ok(k)]) # _Michael S. Branicky_, Apr 16 2023
%Y A361530 Cf. A019549, A083427, A105184.
%K A361530 nonn,base
%O A361530 1,1
%A A361530 _Robert C. Lyons_, Mar 14 2023