| Bytes | Lang | Time | Link |
|---|---|---|---|
| 421 | Bespoke | 250818T082308Z | Josiah W |
| 120 | AWK | 250805T171411Z | xrs |
| 011 | Vyxal 3 | 250802T204528Z | Themooni |
| 288 | SageMath | 230415T065855Z | 138 Aspe |
| 015 | Stax | 230403T145838Z | emirps |
| 010 | 05AB1E | 230225T201649Z | The Thon |
| 213 | brainfuck | 230226T184904Z | Level Ri |
| 010 | 05AB1E | 230226T185514Z | Kevin Cr |
| 055 | JavaScript Node.js | 230226T121224Z | The Thon |
| 045 | Factor | 230226T004006Z | chunes |
| 059 | Perl 5 | 230226T011257Z | Kjetil S |
| 055 | Python 3 | 230226T104933Z | Sisyphus |
| 066 | JavaScript V8 | 230225T214429Z | Arnauld |
| 145 | Excel | 230226T075104Z | Jos Wool |
| 009 | Vyxal | 230225T202359Z | The Thon |
| 040 | Bash + bsdgames + coreutils | 230226T035607Z | Digital |
| 029 | Charcoal | 230225T220540Z | Neil |
| 015 | Japt | 230225T230845Z | noodle p |
| 064 | Wolfram Language Mathematica | 230225T214306Z | ZaMoC |
| 072 | Retina 0.8.2 | 230225T213124Z | Neil |
| 009 | Jelly | 230225T200036Z | caird co |
Bespoke, 421 bytes
all real numbers prime(if not ten/even greater)is:seven,and two,five,three
if numbers are all made prime in the digital way,what are these?we discuss
the full set of prime numbers has lots of entries;still,the set only of any prime-digital one has fewer
if the set had no limit,numbers may be useless for any of maths you can do
but luckily,all of it can show
getting from index will act like so:given N,at index,output N
Given a number n, outputs the nth term in the sequence.
Each of the terms are hardcoded, which takes up most of the program; the snippet given N,at index,output N is what retrieves and outputs the correct term.
AWK, 120 bytes
END{for(i=1;i++<1e4;){for(j=1;i%++j;);for(k=z=0;k++<4;)z+=gsub(substr("2357",k,1),"&",i)~1
if(j~i&&z~length(i))print i}}
END{for(i=1;i++<1e4;){ # to 10k
for(j=1;i%++j;); # prime check
for(k=z=0;k++<4;) # traverse 2357
z+=gsub(substr("2357",k,1),"&",i)~1 # count uniques
if(j~i&&z~length(i)) # if prime and all unique
print i}} # output
Vyxal 3, 11 bytes
kæʎf:℗A$/u∧
kæʎf:℗A$/u∧
kæ # all primes
ʎ # filtered by
f ℗A # are the digits all prime?
: $ ∧ # and
/u # are the digits all different (invariant under unique)
💎
Created with the help of Luminespire.
<script type="vyxal3">
kæʎf:℗A$/u∧ }10⊖
##^force snippet to terminate after 10
</script>
<script>
args=[]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>
SageMath, 288 bytes
Golfed version, run it online!
from itertools import permutations, chain, combinations; from sage.all import is_prime; print([int(''.join(map(str, p))) for p in chain.from_iterable(permutations(s) for s in chain.from_iterable(combinations({2, 3, 5, 7}, r) for r in range(1, 5))) if is_prime(int(''.join(map(str, p))))])
Ungolfed version, run it online!
from itertools import permutations, chain, combinations
from sage.all import is_prime
digits = {2, 3, 5, 7}
subsets = chain.from_iterable(combinations(digits, r) for r in range(1, len(digits) + 1))
perms = chain.from_iterable(permutations(s) for s in subsets)
nums = (int(''.join(map(str, p))) for p in perms)
primes = [n for n in nums if is_prime(n)]
print(primes)
Stax, 15 bytes
¢\W░i*δÿ╛ñê╠≤▬J
This is Packed Stax, which when unpacked represents the following 18 bytes
VIfEccu=^+_+{|pm|A
VIf # filter the following over infinity
E cu= # Are all the digits in the number unique?
c ^+ # Increment this and add it to the list (yielding prime value 2 for truthy)
_+ # add the current value to the list
|A # are all of the values in this list
{|pm # prime?
05AB1E, 14 11 10 bytes
∞ʒÐÙQiDªpP
Doesn't halt after printing all of them so you'll have to press the stop button.
-1 thanks to @KevinCruijssen
Explanation
∞ʒ # All positive integers filtered by:
DÙQ # Digits are unique
i # And:
Dª # Its digits with itself appended
pP # Are all prime
brainfuck, 213 bytes
-[----->+>+>+<<<]>-.---.>.<.>++.<.>++.<.>>-.+.<<.>>.<.<.>--.>.<<.>++.>.<<.>>-.<--.++.<.>--.>.+.<<.>>-.+.<.++.<.>>-.<.--.>+.<<.>>.-.<.++.<.>>+.<--.>-.<++.<.>--.>.+.<++.<.>--.>-.<++.>+.<<.>.>-.<--.>+.<<.>++.--.>-.+.
Sets up 3 cells with ASCII 255/5=51 (character 3) then produces the output hunt and peck style (with increments and decrements as necessary).
Cell 1 is used to print 2 and thereafter the separator /
Cell 2 is used to print 3 5 7 and thereafter the digits 5 & 7
Cell 3 is used to print the digits 2 and 3
It's possible that a 4th cell may lead to shorter code by allowing separate cells to be used for 5 and 7. I may investigate this later.
05AB1E, 10 bytes
₄ÅpʒÐÙSpÏQ
Outputs the entire sequence.
Alternative 10-byter that I deemed different enough for its own answer. Make sure to upvote @TheThonnu's 10-bytes 05AB1E answer as well!
Explanation:
₄ # Push 1000
Åp # Pop and push a list of the first 1000 prime numbers (up to 7919)
ʒ # Filter it by:
Ð # Triplicate the prime number
Ù # Pop one copy, and uniquify its digits
Sp # Check for each unique digit whether it's a prime number
Ï # Pop another copy, and only keep its digits at the truthy indices
Q # Check if the two integers are still the same
# (after which the filtered list is output implicitly)
JavaScript (Node.js), 58 57 55 bytes
n=>'%5Iāȋवુಹᑵᒙ᱕ᵣ'.charCodeAt(n)
Port of Sisyphus's Python answer.
-3 thanks to @Arnauld
Factor, 64 45 bytes
[ "%5Iāȋवુಹᑵᒙ᱕ᵣ"nth ]
-19 by porting Sisyphus' Python answer.
Returns the nth number in the sequence.
JavaScript (V8), 66 bytes
Prints the sequence and keeps looping forever.
{for(n=x=2;;)n%--x||x>1|/(.).*\1|[^2357]/.test(x=n++)||print(n-1)}
JavaScript (V8), 71 bytes
Prints the sequence and stops.
{for(n=x=2;n<8e3;)n%--x||x>1|/(.).*\1|[^2357]/.test(x=n++)||print(n-1)}
Excel, 145 bytes
=LET(
a,SEQUENCE(6^5),
b,FILTER(a,MMULT(N(LEN(a)-LEN(SUBSTITUTE(a,{2,3,5,7},""))=1),{1;1;1;1})=LEN(a)),
FILTER(b,MMULT(N(MOD(b,TOROW(a))=0),a^0)=2)
)
Vyxal, 12 11 9 bytes
Þp~Þu'fæA
Prints the sequence infinitely.
Saved a byte by using a trick from caird's Jelly answer.
Saved 2 bytes thanks to emanresu A.
Explanation
Þp~Þu'fæA
Þp # All primes
~Þu # Filtered by are their digits unique
'fæA # Filtered by are their digits all prime
Old:
Þun:fpæA∧)l
)l # First n non-negative integers where:
Þu # It has unique digits
∧ # And
n:fp # Its digits with it prepended
æA # All are prime
Charcoal, 29 bytes
IΦ×φχ∧⬤”)∨∧i#”‹№IιIμIλ⬤…²ι﹪ιλ
Try it online! Link is to verbose version of code. Explanation:
φ Predefined variable `1000`
× Multiplied by
χ Predefined variable `10`
Φ Filtered where
”...” Compressed string `1122121211`
⬤ All characters satisfy
№ Count of
μ Inner index
I Cast to string
ι In outer value
I Cast to string
‹ Is less than
λ Current character
I Cast to integer
∧ Logical And
… Range from
² Literal integer `2`
ι To current value
⬤ All values satisfy
ι Outer value
﹪ Modulo (i.e. is not divisible by)
λ Inner value
I Cast to string
Implicitly print
34 bytes for a less inefficient version:
⊞υωFυF⁺ι⁻⪪2357¹⪪ι¹⊞υκIΦIυ∧ι⬤…²ι﹪ιλ
Try it online! Link is to verbose version of code. Explanation:
⊞υω
Start with the empty string.
Fυ
Loop over the strings of digits.
F⁺ι⁻⪪2357¹⪪ι¹
Append each prime digit that isn't yet present.
⊞υκ
Save the new strings to the list of numbers with distinct prime digits.
IΦIυ∧ι⬤…²ι﹪ιλ
Output only those strings that represent primes.
33 bytes by using the newer version of Charcoal on ATO:
⊞υωF⁴«≔ΣE2357⁺κΦυ¬№μκυIΦIυ⬤…²κ﹪κμ
Attempt This Online! Link is to verbose version of code. Explanation:
⊞υω
Start with the empty string.
F⁴«
Loop 4 times.
≔ΣE2357⁺κΦυ¬№μκυ
For each prime digit, prefix it to all previous strings that do not already contain that digit, and concatenate all of the resulting lists.
IΦIυ⬤…²κ﹪κμ
Output only those strings that represent primes.
Japt, 15 bytes
Èì_â fjöX©j}jU
Outputs the first \$n\$ entries in the sequence.
Explanation:
Èì_â fjöX©j}jU # input stored in U
È }jU # get first U numbers where the following is true:
ì_ # convert to digits
â # keep unique digits
fj # remove non-prime digits
öX # does this result in the same number?
©j # and check the original is prime
Wolfram Language (Mathematica), 64 bytes
Select[FromDigits/@Join@@Permutations/@Subsets@{2,3,5,7},PrimeQ]
Retina 0.8.2, 72 bytes
1¶11¶111¶4$*
+%1`1
2$'¶$`3$'¶$`5$'¶$`7
A`(.).*\1
.+
$*
A`^(11+)\1+$
%`1
Try it online! Outputs all the terms of the sequence. Explanation:
1¶11¶111¶4$*
Insert 1, 2, 3, and 4 1s.
+%1`1
2$'¶$`3$'¶$`5$'¶$`7
Expand into all possible integers with up to 4 prime digits.
A`(.).*\1
Remove integers with duplicate digits.
.+
$*
Convert to unary.
A`^(11+)\1+$
Filter out composite numbers.
%`1
Convert to decimal.
Jelly, 11 9 bytes
;DẒ;ŒQẠµ#
Takes \$1 \le n \le 18\$ on STDIN and returns the first \$n\$
How it works
;DẒ;ŒQẠµ# - Main link. Takes no arguments
µ - Previous chain as a monad f(k):
D - Digits of k, D
; - Prepnd k
Ẓ - Prime?
ŒQ - Unique sieve; Cast k to digits, replace a digit with a 1 if it hasn't appeared before, else 0
; - Concatenate the two lists
Ạ - All truthy?
# - Read n from STDIN. Starting k=0, count up until n k's return true under f(k)
The way ŒQ works can be shown e.g. with \$k = 75523\$:
[7, 5, 5, 2, 3]
ŒQ:[1, 1, 0, 1, 1]
It auto-casts \$k\$ to digits, then replaces all but the first occurence of each element with 0.