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

Home > Numbers > Sequences
Before and After (Posted on 2004-07-23) Difficulty: 3 of 5
If all the irreducible fractions between 0 and 1, with denominators at most 99, are listed in ascending order, which two fractions would be before and after 11/21? Determine which two fractions are adjacent to 34/87 in this listing.

See The Solution Submitted by Federico Kereki    
Rating: 4.5000 (4 votes)

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

 45 / 86 ( .5232558139534884 )
 11 / 21 ( .5238095238095238 )
 43 / 82 ( .524390243902439 )

 25 / 64 ( .390625 )
 34 / 87 ( .3908045977011494 )
 9 / 23 ( .391304347826087 )

from

DEFDBL A-Z
CLS
numGoal = 11: denGoal = 21: valgoal = numGoal / denGoal
lower = 0: upper = 1
FOR num = 1 TO 98
 FOR den = num + 1 TO 99
  IF num <> numGoal OR den <> denGoal THEN
    value = num / den
    IF value > lower AND value < valgoal THEN
      lower = value
      lowNum = num: lowDen = den
      EXIT FOR
    ELSEIF value < upper AND value > valgoal THEN
      upper = value
      highNum = num: highDen = den
      EXIT FOR
    ELSEIF value < lower THEN EXIT FOR
    END IF
  END IF
 NEXT
NEXT

PRINT lowNum; "/"; lowDen; "("; lower; ")"
PRINT numGoal; "/"; denGoal; "("; valgoal; ")"
PRINT highNum; "/"; highDen; "("; upper; ")"

numGoal = 34: denGoal = 87: valgoal = numGoal / denGoal
lower = 0: upper = 1
FOR num = 1 TO 98
 FOR den = num + 1 TO 99
  IF num <> numGoal OR den <> denGoal THEN
    value = num / den
    IF value > lower AND value < valgoal THEN
      lower = value
      lowNum = num: lowDen = den
      EXIT FOR
    ELSEIF value < upper AND value > valgoal THEN
      upper = value
      highNum = num: highDen = den
      EXIT FOR
    ELSEIF value < lower THEN EXIT FOR
    END IF
  END IF
 NEXT
NEXT

PRINT
PRINT lowNum; "/"; lowDen; "("; lower; ")"
PRINT numGoal; "/"; denGoal; "("; valgoal; ")"
PRINT highNum; "/"; highDen; "("; upper; ")"

 


  Posted by Charlie on 2004-07-23 11:19:08
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 (11)
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