mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Travis CI: Add pytest --doctest-modules maths (#1020)
* Travis CI: Add pytest --doctest-modules maths * Update lucas_series.py * Update lucas_series.py
This commit is contained in:
parent
b35f5d971b
commit
93fdc9f2a1
|
@ -18,10 +18,6 @@ script:
|
|||
--ignore=machine_learning/perceptron.py
|
||||
--ignore=machine_learning/random_forest_classification/random_forest_classification.py
|
||||
--ignore=machine_learning/random_forest_regression/random_forest_regression.py
|
||||
--ignore=maths/abs_min.py
|
||||
--ignore=maths/binary_exponentiation.py
|
||||
--ignore=maths/lucas_series.py
|
||||
--ignore=maths/sieve_of_eratosthenes.py
|
||||
after_success:
|
||||
- python scripts/build_directory_md.py
|
||||
- cat DIRECTORY.md
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from abs import abs_val
|
||||
from .abs import abs_val
|
||||
|
||||
|
||||
def absMin(x):
|
||||
"""
|
||||
# >>>absMin([0,5,1,11])
|
||||
>>> absMin([0,5,1,11])
|
||||
0
|
||||
# >>absMin([3,-10,-2])
|
||||
>>> absMin([3,-10,-2])
|
||||
-2
|
||||
"""
|
||||
j = x[0]
|
||||
|
@ -13,9 +14,11 @@ def absMin(x):
|
|||
j = i
|
||||
return j
|
||||
|
||||
|
||||
def main():
|
||||
a = [-3,-1,2,-11]
|
||||
print(absMin(a)) # = -1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -17,11 +17,12 @@ def binary_exponentiation(a, n):
|
|||
return b * b
|
||||
|
||||
|
||||
try:
|
||||
BASE = int(input('Enter Base : '))
|
||||
POWER = int(input("Enter Power : "))
|
||||
except ValueError:
|
||||
print("Invalid literal for integer")
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
BASE = int(input("Enter Base : ").strip())
|
||||
POWER = int(input("Enter Power : ").strip())
|
||||
except ValueError:
|
||||
print("Invalid literal for integer")
|
||||
|
||||
RESULT = binary_exponentiation(BASE, POWER)
|
||||
print("{}^({}) : {}".format(BASE, POWER, RESULT))
|
||||
RESULT = binary_exponentiation(BASE, POWER)
|
||||
print("{}^({}) : {}".format(BASE, POWER, RESULT))
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
# Lucas Sequence Using Recursion
|
||||
|
||||
def recur_luc(n):
|
||||
if n == 1:
|
||||
return n
|
||||
if n == 0:
|
||||
return 2
|
||||
return (recur_luc(n-1) + recur_luc(n-2))
|
||||
|
||||
limit = int(input("How many terms to include in Lucas series:"))
|
||||
print("Lucas series:")
|
||||
for i in range(limit):
|
||||
print(recur_luc(i))
|
||||
"""
|
||||
>>> recur_luc(1)
|
||||
1
|
||||
>>> recur_luc(0)
|
||||
2
|
||||
"""
|
||||
if n == 1:
|
||||
return n
|
||||
if n == 0:
|
||||
return 2
|
||||
return recur_luc(n - 1) + recur_luc(n - 2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
limit = int(input("How many terms to include in Lucas series:"))
|
||||
print("Lucas series:")
|
||||
for i in range(limit):
|
||||
print(recur_luc(i))
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
import math
|
||||
|
||||
N = int(input("Enter n: "))
|
||||
|
||||
|
||||
def sieve(n):
|
||||
"""Sieve of Eratosthones."""
|
||||
l = [True] * (n + 1)
|
||||
|
@ -26,4 +23,5 @@ def sieve(n):
|
|||
return prime
|
||||
|
||||
|
||||
print(sieve(N))
|
||||
if __name__ == "__main__":
|
||||
print(sieve(int(input("Enter n: ").strip())))
|
||||
|
|
Loading…
Reference in New Issue
Block a user