PR3_Skriptsprachen_GruppeD_SL1/s1_a4.py

11 lines
349 B
Python
Raw Permalink Normal View History

2022-11-05 15:33:32 +01:00
import math
if __name__ == "__main__":
2023-03-30 01:29:11 +02:00
# 4.1
series_value = round(math.pi**2/6, 6)
approximate_value = 0
2022-11-05 15:33:32 +01:00
divider = 1
2023-03-30 01:29:11 +02:00
while series_value != round(approximate_value, 6):
2023-04-01 02:30:56 +02:00
approximate_value = 1/divider**2
2022-11-05 15:33:32 +01:00
divider += 1
2023-03-30 01:29:11 +02:00
print("The sum equals", series_value, "after adding", divider-1, "reciprocal square numbers.")