Created
October 29, 2011 19:02
-
-
Save hkulekci/1324935 to your computer and use it in GitHub Desktop.
my first python example to use 25 terms to evaulate two series.
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
| def fak (x): | |
| if x == 0: | |
| return 1 | |
| else: | |
| return x * fak(x-1) | |
| i = 0 | |
| t = 8.3 | |
| result1 = 0 | |
| result2 = 0 | |
| channel = 0 | |
| import math | |
| while i < 25: | |
| if math.fmod(i,2) == 0: | |
| channel = math.pow(t,i) / fak(i) | |
| else: | |
| channel = math.pow(t,i) / fak(i) * -1 | |
| result1 += channel | |
| #print channel | |
| i = i + 1 | |
| i = 0 | |
| while i < 25: | |
| result2 += math.pow(t,i) / fak(i) | |
| #print channel | |
| i = i + 1 | |
| if result2 != 0: | |
| result2 = 1 / result2 | |
| print "Result 1 : {0} " . format(result1) | |
| print "Result 2 : {0} " . format(result2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment