8
1
Definition
A square-free semiprime is a natural number that is the product of two distinct prime numbers.
The task
Given a natural number n
, count all square-free semiprimes less than or equal to n
.
Details
Please write a function or procedure that accepts a single integer parameter and counts all square-free semiprimes less than or equal to its parameter. The count must either be a return value of a function call or be printed to STDOUT.
Scoring
The answer with the fewest number of characters wins.
In the event of a tie, the following criteria will be used in order:
Tallest personBest time-complexity
- Worst space-complexity
Examples
f(1) = 0
f(62) = 18
f(420) = 124
f(10000) = 2600
http://oeis.org/A180074 ? – Ev_genus – 2012-08-03T00:50:43.443
oops, sorry, but no that sequence is not quite right due to the congruence restriction (e.g., 35=57 and 55=511 are not included). I will add a few example solutions to this particular problem momentarily. – ardnew – 2012-08-03T01:29:01.977
2http://oeis.org/A006881 – Peter Taylor – 2012-08-03T07:07:05.530
What happens if a language doesn't have STDOUT (like javascript)? Use
console.log
? – Inkbug – 2012-08-03T11:23:54.103@Inkbug isn't javascript capable of returning a value from a function? – ardnew – 2012-08-03T14:17:36.637
@ardnew Oh, I missed that. Sorry. – Inkbug – 2012-08-03T14:44:55.240