Taking advantage of the fact that thepartitions have only 3 elements.

If the first number is i, the second number can be anything from 1 to 999999-iand the third number is then uniquely fixed.

Since ican run from 1 to 999998, the total number of such choices is (-: 999998 * 999999).

But this counts triplets more than once.  Any triplet in which the numbers are unique will be counted 6 times.

Any triplet containing a repetition will be counted 3 times: once when i is the unrepeated number and twice when i is the repeated number.  This happens here whenever i is even, thus
(-:999998) times.

Any triplet containing all 3 numbers equal will be counted just once, but there aren't any of them.

To find the unique triplets, we take (-: 999998 * 999999), add in 3 * (-:999998) to bring the 3-times-repeated cases up to 6-times-repeated, then divide by 6:

0 ": 6 %~ (-: 999998 * 999999) + 3 * -: 999998

83333333333


Henry Rich



---
This email has been checked for viruses by AVG.
http://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to