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

Home > Numbers
ABCD's Of Greatest Divisor (Posted on 2009-09-24) Difficulty: 3 of 5
The greatest common divisor of five positive integers ABCD, 1920CD41, 496BC3, 872AB76 and 10A25D8 is ≥ 2, where each of A, B, C and D represents a different base 10 digit from 0 to 9.

Determine all possible quadruplet(s) (A, B, C, D) that satisfy the given conditions.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution QB version Comment 3 of 3 |

 

 A  B  C  D      the Numbers-------------------
 8  5  2  4    8524  19202441  496523  8728576  1082548
 GCD: 2131
 only 1 solution

 

DECLARE FUNCTION gcd# (a#, b#)
DEFDBL A-Z

FOR a = 0 TO 9
 used(a) = 1
FOR b = 0 TO 9
 IF used(b) = 0 THEN
  used(b) = 1
FOR c = 0 TO 9
 IF used(c) = 0 THEN
  used(c) = 1
FOR d = 0 TO 9
 IF used(d) = 0 THEN
  used(d) = 1

  abcd = a * 1000 + b * 100 + c * 10 + d
  cd = (19200 + c) * 1000 + d * 100 + 41
  bc = (4960 + b) * 100 + c * 10 + 3
  ab = (8720 + a) * 1000 + b * 100 + 76
  ad = (100 + a) * 10000 + (250 + d) * 10 + 8

  g = gcd(abcd, cd)
  g = gcd(g, bc)
  g = gcd(g, ab)
  g = gcd(g, ad)
  IF g >= 2 THEN
   PRINT a; b; c; d, abcd; cd; bc; ab; ad, g: ct = ct + 1

  END IF

  used(d) = 0
 END IF
NEXT
  used(c) = 0
 END IF
NEXT
  used(b) = 0
 END IF
NEXT
 used(a) = 0
NEXT

PRINT ct

FUNCTION gcd (a, b)
 dnd = a: dvr = b
 DO
  q = INT(dnd / dvr): r = dnd - q * dvr
  dnd = dvr: dvr = r
 LOOP UNTIL dvr = 0
 gcd = dnd
END FUNCTION

 


  Posted by Charlie on 2009-09-24 14:28:03
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 (13)
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