Let \$n\$ be some positive integer. We say that \$n\$ is of even kind if the prime factorisation of \$n\$ (counting duplicates) has an even number of integers. For example, \$6 = 2 \times 3\$ is of even kind. Likewise, we say \$n\$ is of odd kind of the prime factorisation of \$n\$ has an odd number of integers, such as \$18 = 2 \times 3 \times 3\$. Note that as the prime factorisation of \$1\$ contains \$0\$ primes, it is of even kind.
Let \$E(n)\$ be the count of positive integers of even kind less than or equal to \$n\$, and \$O(n)\$ be the count of positive integers of odd kind less than or equal to \$n\$. For example, for \$n = 14\$, we have
- \$E(14) = 6\$ (\$1, 4, 6, 9, 10, 14\$), and
- \$O(14) = 8\$ (\$2, 3, 5, 7, 8, 11, 12, 13\$)
You are to write a program which takes some positive integer \$n \ge 1\$ as input, and outputs the two values \$E(n)\$ and \$O(n)\$. You may input and output in any convenient method, and you may output the two outputs in any format that consistently presents the values (e.g. you cannot output one in unary and another in decimal), and that clearly distinguishes between the two (typically, has some kind of obvious delimiter).
This is a code-golf challenge, so the shortest code in bytes wins.
Test cases
n -> [E(n), O(n)]
1 -> [1, 0]
2 -> [1, 1]
3 -> [1, 2]
4 -> [2, 2]
5 -> [2, 3]
6 -> [3, 3]
7 -> [3, 4]
8 -> [3, 5]
9 -> [4, 5]
10 -> [5, 5]
11 -> [5, 6]
12 -> [5, 7]
13 -> [5, 8]
14 -> [6, 8]
15 -> [7, 8]
16 -> [8, 8]
17 -> [8, 9]
18 -> [8, 10]
19 -> [8, 11]
20 -> [8, 12]
1
? The Japt answer does that but I don't feel like it's right (even though that would make things simpler for me) \$\endgroup\$1
and a0
. If, however, you are outputting only unary, then outputting an empty string is okay (as that's0
in unary), but otherwise, there should be two clear values output. \$\endgroup\$