# Count on cantor help!?

Printable View

• 04-06-2009, 12:39 AM
dianar17
Count on cantor help!?
I need some help coming up with the correct coding for the count on cantor problem. You can read an explanation of the problem in here:
Code:

`werdna1222coldcodes.blogspot.com/2008/10/264-count-on-cantor.html`
The only difference is that I have to read the number from a file (already did it) and it does work that way, BUT I also have to calculate the sum of all terms before that number.

Example:
3 is 2/1 - Sum: 2 1/2
14 is 2/4 - Sum: 22 3/4

I'm using a class named Racional, which I call from this problem to set the numerator and denominator of my number, and after that I call the sum method (also in my racional class). I can't seem to find the problem, but when I run the program it shows an error regarding my sum method. I did a somewhat similar code and the sum does work but not in the right way.

Here's my racional class
Code:

`fileden.com/files/2007/4/15/987298/PruebaRacional.java`
And my code
Code:

`fileden.com/files/2007/4/15/987298/Tarea412.java`
I put a link to the files since they are quite long.
I would really appreciate it if someone could help me!
• 04-06-2009, 06:22 AM
mtyoung
Code:

```for (int t = 0; t < n.length; t++) {   // code }```
have you found any Strange in the for loop
what if the text file only contain 3 numbers, how many times do the looping should do? is 3, not n.length