Skip to content

Instantly share code, notes, and snippets.

@areyoualex
Created April 10, 2018 20:38
Show Gist options
  • Save areyoualex/2a45b3d1f0c6b822807c458cf0a29935 to your computer and use it in GitHub Desktop.
Save areyoualex/2a45b3d1f0c6b822807c458cf0a29935 to your computer and use it in GitHub Desktop.
A python snippet that will calculate a geometric sequence for you.
t1 = int(input("Enter the first term (t1): "))
tn = int(input("Enter the final term (tn): "))
diff = int(input("Enter the spaces in between: "))
r = ( tn/t1 )**(1/(diff+1))
print("R is "+str(r));
print("t1 is "+str(t1));
print("tn is "+str(tn));
for i in range(1, diff+3):
print(str(i) +": " + str(t1*r**(i-1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment