Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Fraction Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
KONjbnj




PostPosted: Thu May 25, 2006 12:56 pm   Post subject: Fraction Help

I have everything in the assignment done except for one part that I can't figure out. I have to reduce large fractions to its smallest form (ie 20/48). I can do easy ones like 2/12 and stuff, but ones where it doesn't equally reduce is confusing. I'll show you what I have, and tell me how I should go about doing it. Do I need to modify one of the ways that I already reduce fractions, or do I need to do it in a whole new way?


fraction.txt
 Description:
The datafile it gets the numbers from

Download
 Filename:  fraction.txt
 Filesize:  165 Bytes
 Downloaded:  106 Time(s)


ICS10.T
 Description:

Download
 Filename:  ICS10.T
 Filesize:  5.88 KB
 Downloaded:  85 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Thu May 25, 2006 5:20 pm   Post subject: Re: Fraction Help

KONjbnj wrote:
Do I need to modify one of the ways that I already reduce fractions, or do I need to do it in a whole new way?


You should be able to reduce all fractions with one system. Though perhaps some optimizations for specific cases (such as 2/12, where the numerator is a factor of the denominator) could be good.

The general way to reduce a fraction is as follows:

  1. Factor both numerator and denominator into their prime factors
  2. Cancel prime factors that are common to both numerator and denominator
  3. Calculate new numerator and denominator by multiplying out the prime factors that remain for each
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: