Skip to content

Commit

Permalink
Özel Denklem
Browse files Browse the repository at this point in the history
  • Loading branch information
HarunUYGUC committed Apr 19, 2024
1 parent 29f65a7 commit c919af6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Algorithms/Algorithms/ozel-denklem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
sin(x) = x - (x^2 / 2!) + (x^4 / 4!) - (x^6 / 6!) ...
şeklinde giden denklemin ilk 10 teriminin sonucunu hesaplayınız.
"""

def faktoriyel(x):
fak = 1

for i in range(1, x + 1):
fak *= i

return fak

x = int(input("Radyan cinsinden bir sayı giriniz: "))

adet = 1 # x var.
sonuc = x
sayi = 2 # us ve faktoriyel hesabı için

while (adet < 10):
adet += 1

if (adet % 2 == 0):
sonuc += - x**sayi / faktoriyel(sayi)
else:
sonuc += x**sayi / faktoriyel(sayi)

sayi += 2

print(f"Sonuç = {sonuc}")

0 comments on commit c919af6

Please sign in to comment.