18
The Task
Write a program or function that, when passed a numerical input x
, prints or returns the primes beneath the square root of x
1 that are not factors of x
.
Examples
Let f(x)
be the function called:
>>> f(4)
[]
>>> 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]
Bonus Rules
- You may use any builtins that your language provides.
- Your program must support an
x
input as high as the upper bound defined by your language.
1 Using the square root as only primes below the square root can actually be involved within the factors of x
. Without making this restriction, larger numbers would have a lot of excess printed numbers.
3"Only primes below the square root can actually be involved within the factors of
x
" isn't true: a number can have one prime factor that's larger than its square root. Indeed, your first two examples (5 and 20) have this property, as do all primes, twice all odd primes, .... – Greg Martin – 2016-12-09T00:34:00.1231@GregMartin Yes, they can - but they cannot be found within the first half of the factors. It makes sense not to include 7 in the missing primes of 48 as 7^2 is greater than 48. (my reasoning lies there) – Addison Crump – 2016-12-09T01:47:55.133