# Write a program to compute R∞

Hi, I’m really stuck on this code I have to write on python. could someone help? Thankyou

Firstly, welcome to the forums.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://www.freecodecamp.org/learn.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / repl.it / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding Hi the first picture is a different example of a while loop

Ok, what code do you have so far for computing R_infty?

i have this but i’m not sure how to do the while loop

As to the calculations, what happened as you plotted `a` to show the different values of `R_n`?

i’m also confused why they put for i in range (n-1) is it from 50 counting down

I havent managed to calculate the values as i’m really confused

This is an interactive version of your code:

``````# Setup variables
r = 100.0
s = 10000.0
n = 50
a = [r + s] # R_1

# Calculate R_n
for i in range(n - 1):
a.append(r + s*a[-1]/(s + a[-1]))

# Plot
import matplotlib.pyplot as plt
plt.plot(a)
plt.show()
``````

So what does the graph show is happening to `R_n`?

r_n is going to infinity ?

I think you may be misinterperting the graph. The x axis of the graph shows `n`. So as `n` gets bigger, the curve representing `R_n` does what?

so R_n vs n showing as n increases R_n decreases? Yes, but decreases to where? Does it keep decreasing forever?

I promise, my question here has a purpose. Once you can describe what happens to `R_n` as `n` gets bigger and bigger, then you can make a loop that computes `R_infty`.

no it intersects at about 10000

Ok, so how about making the `while` loop generate values of `R_n` for bigger and bigger values of `n` until the values of `R_n` stop changing? Then you’ll have `R_infty`.

careful, that is R_0
you want R_infy, so the value to the right of the diagram

1 Like

Right, different number of 0s

so i change the value of n?