Count Specific Total Numbers from a Set

  • Thread starter Thread starter Paul Black
  • Start date Start date
Brilliant Dana, thanks VERY much for the detailed explanation and
code.

Your code will satisfy several other tests I want to produce very
nicely that use a single set of numbers.
I like the idea of checking that all combinations are present, very
neat.
Could you please explain what the variables "R", "n", "NPrime",
"PrimeQ" & "S" actually do please. It appears that the variable "R"
means one thing at the beginning of the code and something else
further down.

I would like to do two more tests, mainly count the number of Odd &
Even numbers, but that involves two scenarios, one for Odd & the other
for Even. The results should be as follows :-

0 Odd + 6 Even = 134,596
1 Odd + 5 Even = 1,062,600
2 Odd + 4 Even = 3,187,800
3 Odd + 3 Even = 4,655,200
4 Odd + 2 Even = 3,491,400
5 Odd + 1 Even = 1,275,120
6 Odd + 0 Even = 177,100
Totals > = 1,3983,816

I would like to do this by using the actual Odd & Even numbers in the
code itself, because there are other tests I want to produce that also
require using two seperate sets of numbers. That way, I can just enter
the new sets of numbers.

Thanks in Advance.
All the Best.
Paul
 
Instead of Select Case, and looping 49 times, I suppose we could loop 15
times.
As you can see, there are many different ideas one can use.
The idea here is that the Array is initialized with zero anyway, and we are
just setting a few of them to 1.

Dim P As Variant
' Do Once Here
For Each P In Array(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47)
n(P) = 1&
Next P

I'm not sure of your second question, as I se eyou already have a solution
to your Odd/Even query.
 
Thanks for the reply Dana,

I will have a play around over the next week with your suggestions.
What does the "&" mean in "n(P) = 1&" please.
Also, it would be appreciated if you could just explain what the
variables "R", "n", "NPrime", "PrimeQ" & "S" actually do please. It
appears that the variable "R" means one thing at the beginning of the
code and something else further down.

Thanks in Advance.
All the Best.
Paul
 
Back
Top