Skip to content

Commit 683fd0e

Browse files
authored
Merge pull request prabhupant#191 from robbyrenz/math-pep8-correction
fix PEP 8 issues
2 parents 6cf9a3b + ffa9769 commit 683fd0e

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1+
# Program that prints out the fibonacci sequence until a given number
2+
13
def calc_fib(num):
2-
while len(fib)<=num:
4+
while len(fib) <= num:
35
n = len(fib)
4-
fib.append((fib[n-1]+fib[n-2]))
6+
fib.append((fib[n-1] + fib[n-2]))
57

68
def main():
79
print("Enter the Position of the Number in the Sequence or \'0\' to Quit: ")
810
num = 0
911
fib = list()
1012
fib.append(0)
1113
fib.append(1)
14+
1215
while True:
1316
num = int(input())
14-
if(num<=0):
17+
if(num <= 0):
1518
break
1619

17-
if len(fib)<=num:
20+
if len(fib) <= num:
1821
calc_fib(num)
1922

20-
print('Fibonacci Number at Position '+str(num)+' is: '+str(fib[num]))
23+
print('Fibonacci Number at Position ' + str(num) + ' is: ' + str(fib[num]))
2124

2225
if __name__ == '__main__':
2326
main()

algorithms/math/greatest_common_divisor.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77
"""
88
# Iterative Solution
99
def gcd(x, y):
10-
if x==0:
10+
if x == 0:
1111
return y
12-
if y==0:
12+
if y == 0:
1313
return x
1414

15-
while x%y != 0:
16-
rem = x%y;
15+
while x % y != 0:
16+
rem = x % y;
1717
x = y
1818
y = rem
1919

2020
return y
2121

2222
# Recursive Solution
2323
def gcd(x, y):
24-
if x==0:
24+
if x == 0:
2525
return y
26-
if y==0:
26+
if y == 0:
2727
return x
2828

29-
return gcd(y, x%y)
29+
return gcd(y, x % y)

algorithms/math/prime.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
def prime(limit):
22

33
count = 1
4-
while(count<limit):
4+
while (count < limit):
55

66
flag = 0
7-
for i in range(3,count,2):
8-
if (count%i==0):
7+
for i in range(3, count, 2):
8+
if (count % i == 0):
99
flag = 1
1010

11-
if (flag==0):
11+
if (flag == 0):
1212
print(count)
1313

14-
count+=2
14+
count += 2
1515

1616
prime(100)

0 commit comments

Comments
 (0)