g | x | w | all
Bytes Lang Time Link
006Vyxal 3250726T083122ZThemooni
023Uiua240817T000234ZErikDaPa
020APLNARS250723T073117ZRosario
008Japt240817T200004ZShaggy
046Uiua230930T131135Zlyxal
006Vyxal230930T125828Zlyxal
054Haskell161209T193845ZJames Ho
066Retina161211T185148ZMartin E
044Octave161210T000512ZStewie G
076JavaScript ES6161209T000549ZETHprodu
071PowerShell v2+161209T141348ZAdmBorkB
054MATLAB161209T065553Zhwm
063R161209T102602ZJAD
076PHP161209T101947ZTitus
130TSQL161209T102257Zt-clause
010Pyke161209T095104ZBlue
00805AB1E161209T071153ZEmigna
014Wonder161209T052332ZMama Fun
055Ruby161209T043945ZJayDepp
037Perl 6161209T020253ZBrad Gil
062Python 3161209T010615ZDennis
046Mathematica161209T004428ZLegionMa
009MATL161208T224424ZLuis Men
006Jelly161208T225028Zuser6213
010Pyth161208T224817ZTheBikin

Vyxal 3, 6 bytes

√~℗?K⦰

-1 byte by pacman256

Vyxal It Online!

√~℗?K⦰­⁡​‎‎⁡⁠⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢‏⁠‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁢‏⁠‎⁡⁠⁣‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌­
√       # ‎⁡sqrt(input)
 ~      # ‎⁢implicit: turn ^ into a range
 ~℗     # ‎⁣keep only primes
   ?K   # ‎⁤factors of the input
     ⦰  # ‎⁢⁡set difference
💎

Created with the help of Luminespire. Created with the help of Luminespire.

<script type="vyxal3">
√~℗?K⦰
</script>
<script>
    args=[["4"],["5"],["20"],["60"],["100"],["10000"]]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>

Uiua, 23 bytes

▽±:⊙◿.▽∵(=1⧻°/×).↘1⇡⌈√.

Explanation

                    ↘1⇡⌈√. => range between [0, sqrt(x))
        ▽∵(=1⧻°/×).       => keep those that are prime
▽±:⊙◿.                   => keep those that are not divisible

Try this online!

Desmos, 102 bytes

p(x)=\left\{∑_{n=2}^{x-1}0^{mod(x,n)}<1:1,0\right\} => prime checker
a=left[2...\sqrt{x}]                                
f(x)=a[p(a)-0^{mod(x,a)}=1]                         => find the primes that are not divisible by the input

Try this online!

APL(NARS), 20 chars

{(π⍵)∼⍨k/⍨0π¨k←⍳⌊√⍵}

Input one number output one numeric list.

The above would mean: make the range 1..⌊√⍵, to each element, see if it is prime and buil one array of binary value, gets from k the element associated to 1 (or prime numbers) and from that list subtract the elements that factor the input omega.

I do not understand why the void set has to have a type, and the void set can not be ok with each type.

This code above postulate and use one void set or void list for the integers only...

Test:

  f←{(π⍵)∼⍨k/⍨0π¨k←⍳⌊√⍵}
  f 4
┌0─┐
│ 0│
└~─┘
  f 5
┌1─┐
│ 2│
└~─┘
  f 20
┌1─┐
│ 3│
└~─┘
  f 60
┌1─┐
│ 7│
└~─┘
  f 100
┌2───┐
│ 3 7│
└~───┘
  f 10000
┌23─────────────────────────────────────────────────────────────────┐
│ 3 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97│
└~──────────────────────────────────────────────────────────────────┘

Japt, 8 bytes

o¬fj kUâ

Try it

o¬fj kUâ     :Implicit input of integer U
o            :Range [0,U)
 ¬           :Square root of each
  f          :Filter by
   j         :  Is prime?
     k       :Remove
      Uâ     :  Divisors of U

Uiua, 46 bytes

▽∵(=2/+⌕0◿+1⇡.).▽¬≡/+⊞=↷.⊃(+1⇡⌊√)(▽=0◿↷.+1⇡.).

Try it Online

Explained

▽∵(=2/+⌕0◿+1⇡.).▽¬≡/+⊞=↷.⊃(+1⇡⌊√)(▽=0◿↷.+1⇡.).­⁡​‎⁠‎⁡⁠⁢⁣⁢‏⁠‎⁡⁠⁢⁣⁣‏⁠⁠⁠⁠⁠⁠‎⁡⁠⁣⁡⁡‏⁠‎⁡⁠⁣⁡⁢‏⁠⁠⁠⁠⁠⁠⁠⁠⁠⁠⁠‎⁡⁠⁣⁤⁡‏⁠‎⁡⁠⁣⁤⁢‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢⁣⁤‏⁠‎⁡⁠⁢⁤⁡‏⁠‎⁡⁠⁢⁤⁢‏⁠‎⁡⁠⁢⁤⁣‏⁠‎⁡⁠⁢⁤⁤‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁣⁡⁣‏⁠‎⁡⁠⁣⁡⁤‏⁠‎⁡⁠⁣⁢⁡‏⁠‎⁡⁠⁣⁢⁢‏⁠‎⁡⁠⁣⁢⁣‏⁠‎⁡⁠⁣⁢⁤‏⁠‎⁡⁠⁣⁣⁡‏⁠‎⁡⁠⁣⁣⁢‏⁠‎⁡⁠⁣⁣⁣‏⁠‎⁡⁠⁣⁣⁤‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁣⁣⁡‏⁠‎⁡⁠⁣⁣⁢‏⁠‎⁡⁠⁣⁣⁣‏⁠‎⁡⁠⁣⁣⁤‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁣⁢⁣‏⁠‎⁡⁠⁣⁢⁤‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁣⁡⁤‏⁠‎⁡⁠⁣⁢⁡‏⁠‎⁡⁠⁣⁢⁢‏‏​⁡⁠⁡‌⁢⁣​‎‎⁡⁠⁣⁡⁣‏‏​⁡⁠⁡‌⁢⁤​‎‎⁡⁠⁢⁡⁡‏⁠‎⁡⁠⁢⁡⁢‏⁠‎⁡⁠⁢⁡⁣‏⁠‎⁡⁠⁢⁡⁤‏⁠‎⁡⁠⁢⁢⁡‏⁠‎⁡⁠⁢⁢⁢‏⁠‎⁡⁠⁢⁢⁣‏⁠‎⁡⁠⁢⁢⁤‏⁠‎⁡⁠⁢⁣⁡‏‏​⁡⁠⁡‌⁣⁡​‎‎⁡⁠⁢⁢⁢‏⁠‎⁡⁠⁢⁢⁣‏‏​⁡⁠⁡‌⁣⁢​‎‎⁡⁠⁢⁡⁣‏⁠‎⁡⁠⁢⁡⁤‏⁠‎⁡⁠⁢⁢⁡‏‏​⁡⁠⁡‌⁣⁣​‎‎⁡⁠⁢⁡⁢‏‏​⁡⁠⁡‌⁣⁤​‎‏​⁢⁠⁡‌⁤⁡​‎‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏⁠‎⁡⁠⁤⁤‏‏​⁡⁠⁡‌­
                         ⊃(     )(          ).  # ‎⁡To the input, apply:
                           +1⇡⌊√                # ‎⁢  Range [1, sqrt(input)]
                                  ▽=0◿↷.+1⇡.    # ‎⁣  All factors of the input by:
                                        +1⇡.    # ‎⁤    Creating a range [1, input]
                                      ↷.        # ‎⁢⁡    Rolling a copy to the bottom of the stack
                                   =0◿          # ‎⁢⁢    Pushing whether each number in that range divides the input
                                  ▽             # ‎⁢⁣    And keeping only numbers that do
                ▽¬≡/+⊞=↷.                       # ‎⁢⁤  Filter out divisors from the sqrt range by:
                     ⊞=                         # ‎⁣⁡    Table via equality
                  ≡/+                           # ‎⁣⁢    Sum of row
                 ¬                              # ‎⁣⁣    != 0
# ‎⁣⁤Essentially, keep only numbers where the number of occurrences in the divisor list is 0
 ∵(=2/+⌕0◿+1⇡.).                                # ‎⁤⁡Push a mask of whether each number is prime (using the method in my "is a number prime" Uiua answer)
💎

Created with the help of Luminespire.

Vyxal, 6 bytes

√~æ?KF

Try it Online!

It's nice to have a massive toolbox again

Explained

√~æ?KF­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌­
√~æ     # ‎⁡Keep only primes from the range [1, sqrt(input)]
     F  # ‎⁢With items from
   ?K   # ‎⁣Factors of the input
     F  # ‎⁤Removed
💎

Created with the help of Luminespire.

Haskell, 55 54 bytes

f x=[y|y<-[2..x],y*y<x,[z|z<-[1..y],gcd(z*x)y>1]==[y]]

Mostly straightforward nested list comprehensions. GCD performs two roles, testing whether the numbers below y are factors of y and also testing whether y is a factor of x.

Spaced out a little:

f x = [ y|y<-[2..x],     y*y<x,     [z|z<-[1..y], gcd (z*x) y > 1] == [y] ]

Retina, 69 66 bytes

.+
$*
(11\1|^1)+
$#1$*1:$&
M!&`(?!(11+)\1+:)(1+):(?!\2+$)
M%`1
^0

Prints the primes on separate lines, from largest to smallest.

Try it online! (Takes about 10 seconds due to the last two test cases. The header and footer enable a linefeed-separate test suite, and convert the output to comma-separation for readability.)

Explanation

.+
$*

Convert the input to unary.

(11\1|^1)+
$#1$*1:$&

This prepends the square root of the input, separated by :. The square root is computed based on the fact that the square of n is also the sum of the first n odd integers. We can match consecutive odd integers with the forward reference (11\1|^1). In the process the group will be used exactly n times, where n is the largest number whose square fits into the input.

We insert a unary representation of this number with $#1$*1, followed by a colon and the match itself.

M!&`(?!(11+)\1+:)(1+):(?!\2+$)

This matches all the missing primes that fit into the square root. The prime detection is based on the standard prime checking regex, and then we simply make sure that the prime we've just captured does not divide the input with the second lookahead. By using the & option, we get overlapping matches to ensure that we get all primes.

M%`1

This converts each line (i.e. each missing prime) back to decimal by matching the number of 1s. The only issue is that this inserts a zero if no missing primes were found at all.

^0

So this stage removes that zero if it was added.

Octave, 44 bytes

This answer is inspired by MattWH's MATLAB answer, but I've golfed it using some Octave-specific features.

@(x)(y=primes(x^.5))(~ismember(y,factor(x)))

This is an anonymous function that takes the input x. Octave has inline variable assignment and indexing allowing y to first be created in the function (not possible in MATLAB), then used as part of the logical mask created by ismember (again, not possible to do it this way in MATLAB).

JavaScript (ES6), 79 76 bytes

f=(q,n=2,x=n)=>n*n<q?[...--x<2&&q%n?[n]:[],...x>1&&n%x?f(q,n,x):f(q,n+1)]:[]

Based on my recursive primality test function. I feel like there should be a few ways to simplify this, but I can't figure out how...

Test snippet

f=(q,n=2,x=n)=>n*n<q?[...--x<2&&q%n?[n]:[],...x>1&&n%x?f(q,n,x):f(q,n+1)]:[]
<input type="number" step=1 min=4 value=4 oninput="O.innerHTML='['+f(this.value)+']'"><br>
<pre id=O>[]</pre>

PowerShell v2+, 71 bytes

param($n)1..[math]::Sqrt($n)|?{$n%$_-and'1'*$_-match'^(?!(..+)\1+$)..'}

Iterative solution. Takes input $n and creates a range from 1 to the Sqrt($n) (note that the range operator will implicitly cast the upper end to an [int] which will do Banker's Rounding by default). Then uses |?{...} (the Where-Object operator, which acts like a filter) to pull out those numbers where $n%$_ is non-zero (i.e., any remainder to the modulo means it's not a factor, and any non-zero is truthy) -and the usual regex prime test is $true. Those are left on the pipeline, and output is implicit.

Examples

(with some extra formatting to pretty up the output)

PS C:\Tools\Scripts\golfing> 5,20,60,100,10000|%{"f($_)";(.\print-the-missing-primes.ps1 $_)-join', ';""}
f(5)
2

f(20)
3

f(60)
7

f(100)
3, 7

f(10000)
3, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97

NB - This will fail on earlier versions if the input is bigger than around 2500000000, because the .. range operator can only support up to 50,000 items. But, since that is bigger than the default [int] datatype's max value, 2147483647, I'm presuming that to be OK. On my machine, PSv4 Win8.1, however, I can go higher, but I'm not able to find documentation explaining the difference.

MATLAB, 57 54 bytes

function h(p);a=primes(p^.5);a(~ismember(a,factor(p)))

Pretty straightforward, gets an array of primes up to sqrt(p) then removes any that are also factors of p. Prints the output of the last line by default because the semicolon is left off.

R, 58 63 bytes

for(i in 2:sqrt(x<-scan()))if(x%%i&numbers::isPrime(i))print(i)

Loops over all values from 2 to sqrt(x) and checks if they are prime with the numbers package. x%%i calculates x mod i which is 0 -> False if i is a divisor of x and >0 -> True if i is not.

+5 bytes because the numbers::Primes(n) function doesn't allow decimals, while 2:sqrt(x) does work, added prime check to if statement.

PHP, 76 bytes

for($n=1;++$n*$n<$x=$argv[1];){for($i=$n;$n%--$i;);if($i<2&&$x%$n)echo$n,_;}

uses my is_prime solution golfed for $n>1

takes input from command line argument. Run with -r.

TSQL, 130 bytes

DECLARE @v int=10000

,@ INT=2SELECT 2p INTO #
g:INSERT # SELECT @ FROM # HAVING isnull(min(@%p),1)>0SET @+=1IF @*@<@v GOTO g
SELECT*FROM # WHERE @v%p>0

This will only execute once, then you need to drop the temp table to execute again in the same editor

DROP TABLE #

I made a version to test it, it is a bit longer because the online permissions for creating tables is unavailable. For the same reason it doesn't need the drop table though.

Try it online

Pyke, 10 bytes

,BS#_P)QP-

Try it here!

,B         -    int(sqrt(input))
  S        -   range(1, ^+1)
   #_P)    -  filter(^, is_prime)
         - - ^.remove(V)
       QP  -  factors(input)

05AB1E, 8 bytes

tLDpϹfK

Try it online!

Explanation

tL        # range [1 ... sqrt(input)]
  DpÏ     # keep only primes
     ¹fK  # remove factors of input

Wonder, 14 bytes

@(_> > ^#0.5)P

Usage:

(@(_> > ^#0.5)P)10

Takes items from an infinite list of primes while the item is less than the square root of the argument.

Ruby, 55 bytes

require'prime'
->x{Prime.to_a(x**0.5).select{|n|x%n>0}}

A rather lazy answer using the builtin prime enumerator.

Perl 6, 37 bytes

{grep {$^a.is-prime&$_%$a},2.. .sqrt}

Expanded:

{   # bare block lambda with implicit parameter 「$_」

  grep
  {
    $^a.is-prime  # check if it is prime
    &             # and junction
    $_ % $a       # check if the input is not evenly divisible by it
  },
  2.. .sqrt          # Range of values up-to and including squareroot
}

Python 3, 67 62 bytes

f=lambda n,k=1,m=1:k*k<n and(m%k*n%k>0)*[k]+f(n,k+1,m*k*k)or[]

Try it online!

Mathematica, 46 bytes

Select[Prime@Range@PrimePi@Sqrt[a=#],!#∣a&]&

Anonymous function. Takes a number as input and returns a list of numbers as output. The Unicode character is U+2223 DIVIDES for \[Divides].

MATL, 10 9 bytes

X^ZqGYfX-

Try it online!

Explanation

X^    % Implicit input. Square root
Zq    % Array if primes up to that
G     % Push input again
Yf    % Array of prime factors
X-    % Set difference. Implicit display

Jelly, 6 bytes in Jelly's codepage

½ÆRḟÆf

Try it online!

Explanation:

½ÆRḟÆf
 ÆR    All primes less than or equal to
½      the square root of the input
   ḟ   but with the following removed:
    Æf All prime factors of {the input, by default}

Pyth, 10 bytes

fP_T-S@Q2P

A program that takes input of a number and prints a list.

Test suite

How it works

fP_T-S@Q2P   Program. Input: Q
fP_T-S@Q2PQ  Implicit input fill
f            Filter
     S@Q2    the 1-indexed range up to floor(sqrt(Q))
    -    PQ  with the prime factors of Q removed
 P_T         by primality
             Implicitly print