All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Counting triplets II (Posted on 2011-07-30)
Each of A, B and C is a positive integer with A < B < C < 300

Determine the total number of triplets (A, B, C) such that;

(I) A+B+C is divisible by 3, and:

(II) sod(A)*sod(B)*sod(C) is divisible by 5.

Bonus Questions:

(A) Disregarding condition (I), determine the total number of triplets.

(B) Disregarding condition (II), determine the total number of triplets.

Note: sod(x) refers to the sum of digits of x.

 No Solution Yet Submitted by K Sengupta No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution Comment 1 of 1

DECLARE FUNCTION sod# (x#)
DEFDBL A-Z
CLS
FOR a = 1 TO 297
FOR b = a + 1 TO 298
FOR c = b + 1 TO 299
c1fl = 0: c2fl = 0
IF (a + b + c) MOD 3 = 0 THEN
c1ct = c1ct + 1
c1fl = 1
END IF
IF (sod(a) * sod(b) * sod(c)) MOD 5 = 0 THEN
c2ct = c2ct + 1
c2fl = 1
END IF
IF c1fl AND c2fl THEN bothct = bothct + 1
NEXT
NEXT
NEXT

PRINT c1ct; c2ct, bothct

FUNCTION sod (x)
s = 0
st\$ = LTRIM\$(STR\$(x))
FOR i = 1 TO LEN(st\$)
s = s + VAL(MID\$(st\$, i, 1))
NEXT
sod = s
END FUNCTION

finds

1470249  2135269            712009

meaning 712,009 meet both criteria and:

1,470,249 meet the first criterion and this constitutes the answer to B.

2,135,269 meet the second criterion and this is then the answer to part A.

Those that meet both criteria are also counted in the individual criterion counts.

These are out of the 4,410,549 possible combinations of numbers.

 Posted by Charlie on 2011-07-30 17:42:18

 Search: Search body:
Forums (0)