How to reduce a list of fractions
I have a list of integers. I want to divide (n+1) by n. I can do this with no problem, but I can't get the resulting fractions in reduced form. My list has 50 items, but I'll only do a list of 5 here to avoid spamming.
sage: a = [6198089008491993412800, 3099044504245996706400, 2066029669497331137600, 2324283378184497529800, 1239617801698398682560]
sage: c = [(n + 1)/n for n in a]
sage: print (c)
[6198089008491993412801/6198089008491993412800, 3099044504245996706401/3099044504245996706400, 2066029669497331137601/2066029669497331137600, 2324283378184497529801/2324283378184497529800, 1239617801698398682561/1239617801698398682560]
I don't know why Sage doesn't automatically reduce these fractions, but since it doesn't, I've tried multiplying by 1 and using reduce() and simplify(), and have searched everywhere I could think of for an answer, but nothing works. I apologize in advance for asking such a rudimentary question.
n+1 is coprime with n => these fractions are reduced
Thank you! I didn't pay attention to the output of Sage. I'm trying to divide each term in the list by the term before it, but that's not what I asked for in Sage. Alas, I can't figure out how to ask for what I want. I tried using a(n) and a(n+1) and also creating the list L, but I couldn't get either of those to produce what I'm looking for.
(The result I am looking for is [1/2, 2/3, 9/8, 8/15]. )
This is a python question. Learn python first ?
a[0]
will give 6198089008491993412801/6198089008491993412800, for example.for n in range(len(a)-1): ...
Thank you, FrédéricC. I went to Python, which I have been studying, slowly, and (of course) with some help from the Stack Overflow forum, figured out to do this in Python.
Sage is the common short form of SageMath, rather than SM.
Oops! thank you.