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

Home > Just Math
Counting triplets II (Posted on 2011-07-30) Difficulty: 3 of 5
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.)
Solution 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
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information