-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit, adding in simple pi and fibonacci sequence calculators.
- Loading branch information
1 parent
cdb1802
commit 75782cd
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
""" | ||
untitled.py | ||
Created by Chris Wood on 2012-05-22. | ||
Copyright (c) 2012 __MyCompanyName__. All rights reserved. | ||
""" | ||
|
||
import sys | ||
|
||
|
||
def main(): | ||
for i in range(int(sys.argv[1])): | ||
print(fib(i)) | ||
|
||
def fib(n): | ||
return n if n in [0,1] else fib(n-1) + fib(n-2) | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
""" | ||
mac-int.py | ||
Created by Chris Wood on 2012-05-28. | ||
Copyright (c) 2012 __MyCompanyName__. All rights reserved. | ||
""" | ||
|
||
import sys | ||
import os | ||
import Tkinter | ||
from Tkinter import Tk, Label | ||
|
||
|
||
def main(): | ||
root = Tk() | ||
w=Label(root, text="Hi Kay It smells good in here") | ||
|
||
w.pack() | ||
w.mainloop() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
""" | ||
pi.py | ||
Created by Chris Wood on 2012-05-22. | ||
""" | ||
|
||
import sys | ||
|
||
|
||
def main(): | ||
print('===========\n') | ||
pi(int(sys.argv[1])) | ||
print('===========\n') | ||
|
||
#Gregory–Leibniz series | ||
def pi(i): | ||
# set initial value (constant out of series. if any) | ||
pi = 0.0 | ||
divisor = 4.0 | ||
for iteration, value in enumerate(range(1, 2*i, 2), 1): | ||
print('iteration - %s' %(iteration)) | ||
dividend = float(value) | ||
if iteration & 1: # is odd number | ||
pi += divisor/dividend | ||
else: | ||
pi -= divisor/dividend | ||
|
||
print('Pi = %s' %(pi)) | ||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |