Skip to content

Commit 6e76175

Browse files
Add Arithmetic Progression Generator
1 parent 9629aef commit 6e76175

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

arithmetic_progression.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
###########################################################################
2+
3+
# Question - Arithmetic Progression Generator
4+
5+
# # Develop a program that:
6+
# 1- read the first term and the common difference of a arithmetic progression
7+
# 2- show the first 10 terms of this progression
8+
# 3- ask to user if he wants show some more terms
9+
# 4- finish the program when user says he wants to show 0 terms
10+
11+
###########################################################################
12+
13+
print("Arithmetic Progression Generator")
14+
print("-=" * 50)
15+
first_term = int(input("First term: "))
16+
common_difference = int(input("Common difference: "))
17+
term = first_term
18+
cont = 1
19+
more = 10
20+
total = 0
21+
while more != 0:
22+
total += more
23+
while cont <= total:
24+
print(f"{term}", end=" --> ")
25+
term += common_difference
26+
cont += 1
27+
28+
print("PAUSE.\n")
29+
30+
more = int(input("How many terms you want to show more? "))
31+
print(f"\n\nArithmetic Progression was finished with {total} terms shown.\n\n")

0 commit comments

Comments
 (0)