# write a recursive program of rational numbers in java

Page 1 of 1

## 1 Replies - 941 Views - Last Post: 01 March 2014 - 12:36 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=341233&amp;s=02f52c6a3e8559f6ead955ca96ed9bfa&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Varman

Reputation: 0
• Posts: 1
• Joined: 01-March 14

# write a recursive program of rational numbers in java

Posted 01 March 2014 - 12:22 PM

the rational number program can't be found in net
Given below is sequence of rational numbers

1,2,5/2,29/10,941/290,969581/272890.......

Implement a recursive function for the above sequence

if n>0

f(n)=f(n-1)+1/f(n-1)
I can't develop a coding for the above function.. can anyone help me to solve in java?
Is This A Good Question/Topic? 0

## Replies To: write a recursive program of rational numbers in java

### #2 jon.kiparsky

• Beginner

Reputation: 11040
• Posts: 18,855
• Joined: 19-March 11

## Re: write a recursive program of rational numbers in java

Posted 01 March 2014 - 12:36 PM

For any recursive function, the first step is to determine your base case and your inductive step. Start by writing those out in pseudocode, and then try to implement them.

You might want to write a little Rational class to help you out here. Since you're going to have to implement rational arithmetic in some fashion, you might as well try encapsulating it in a class. However, that's not strictly necessary - you can do without it if you want.