Created
February 17, 2023 05:26
-
-
Save eugeneai/6777016fefc1a6a6d165948a7887c4ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Arithmetic progression | |
# Input | |
# Second task : calculate sum of ai | |
debug = True | |
allow_input = False if debug else True | |
if allow_input: | |
n=int(input("Input n: ")) | |
a1=int(input("Input a1: ")) | |
d=int(input("Input d: ")) | |
else: | |
n = 20 | |
a1 = 1 | |
d=10 | |
i=1 | |
a=a1 | |
while i<n: | |
a=a+d | |
i=i+1 | |
if debug: | |
# Check our algorithm | |
b = a1+(n-1)*d | |
assert b == a | |
# Output | |
print('Memeber number', n, 'of the progression is', a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment