Problem Statement
Elly loves "div 2" problems! By this she means problems in which she has to divide by two! She notices that some numbers contain prime numbers in themselves! A number X contains another number Y if Y = X / 2k (here and everywhere later in the statement the results of all divisions are rounded down, i.e., integer divisions), for some non-negative integer k.
She calls all positive integers "prime containers" and defines the size of a prime container as the number of prime numbers contained in that positive integer. For example the size of number 7 is 2, because 7/1 = 7 and 7/2 = 3 are prime; the size of 47 is 5, because 47, 23, 11, 5 and 2 are prime; the size of 959 is 6, since it contains the prime numbers 479, 239, 59, 29, 7 and 3.
Given a positive
Definition
- Class:
- PrimeContainers
- Method:
- containerSize
- Parameters:
- int
- Returns:
- int
- Method signature:
- int containerSize(int N)
- (be sure your method is public)
Notes
- A prime number is a natural number greater than one that has exactly two distinct natural number divisors: 1 and itself.
Constraints
- N will be between 1 and 1,000,000, inclusive.
Examples
10
Returns: 2
The generated sequence is 10, 5, 2, 1. Ten is not a prime, however five and two are.
42
Returns: 2
The Answer to Life, The Universe and Everything is quite poor prime container.
47
Returns: 5
One of the examples in the problem statement.
959
Returns: 6
Another example from the problem statement.
421337
Returns: 2
1
Returns: 0
10
Returns: 2
100
Returns: 1
1000
Returns: 3
10000
Returns: 2
100000
Returns: 2
1000000
Returns: 3
666
Returns: 4
1337
Returns: 5
7
Returns: 2
23
Returns: 4
2879
Returns: 9
2
Returns: 1
3
Returns: 1
11
Returns: 3
111111
Returns: 2
222222
Returns: 2
333333
Returns: 2
444444
Returns: 2
555555
Returns: 3
666666
Returns: 2
777777
Returns: 7
888888
Returns: 2
999999
Returns: 4
16
Returns: 1
131072
Returns: 1
524287
Returns: 7
13
Returns: 2
50
Returns: 1
70
Returns: 2
78
Returns: 2
313
Returns: 3
313131
Returns: 3
424242
Returns: 3
997
Returns: 4
994009
Returns: 2
15015
Returns: 4
11519
Returns: 10
23039
Returns: 11
368633
Returns: 12
982559
Returns: 11
737279
Returns: 12