Python/maths/absMin.py
Vysor df04d94543 Some directories had a capital in their name [fixed]. Added a recursive factorial algorithm. (#763)
* Renaming directories
* Adding a recursive factorial algorithm
2019-04-22 22:53:56 +08:00

20 lines
324 B
Python

from Maths.abs import absVal
def absMin(x):
"""
# >>>absMin([0,5,1,11])
0
# >>absMin([3,-10,-2])
-2
"""
j = x[0]
for i in x:
if absVal(i) < absVal(j):
j = i
return j
def main():
a = [-3,-1,2,-11]
print(absMin(a)) # = -1
if __name__ == '__main__':
main()