How to return only the denominators of a sequence of fractions created by a formula
With essential help from slelievre, I managed to achieve coding to return the fractional 'density' (if that is the right term) of primes between n^2 and (n+1)^2:
for n in range(1, 51):
a = n^2 + 1
b = (n + 1)^2 + 1
c = 2*n
nprimes = sum(1 for p in prime_range(a, b))
d = f"{nprimes}/{c}"
print(d)
Now I want to extract just the denominators of this sequence so that I can find the LCM of all those denominators and then convert all the fractions to have the same LCM denominator. (I cannot just use 2n to find the LCM because the fractions need to be reduced.) I found the command x.denominator(), but it seems to work for only a single fraction of integers. At least that's what I understand the error message to mean when I try d.denominator() or print(d.denominator()), the error message reading "AttributeError: 'str' object has no attribute 'denominator'".
Any help in showing me how to do this would be greatly appreciated.
I have now worked out the LCM by hand (but I still want to be able to do it through SageMath), and the value is a bit over 6 sextillion (6*10^21). I could reduce that number substantially by lowering the range of n down to 30 or 40, but I'd really prefer not to do that. Will I likely run into any problems in the coding I've asked about in my question with the LCM being that large? I'd appreciate anyone's thoughts on this.