Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
Source: https://github.com/github/gitignore/blob/master/Python.gitignore

# User generated
ENV/
.vscode
.idea
.DS_Store
.history


# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
.pytest_cache/

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
.static_storage/
.media/
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# js
node_modules/
.next/

# poetry
poetry.lock
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"ponicode.testSettings.testLocation.locationType": "Same folder as source file",
"ponicode.testSettings.testLocation.path": "{rootDir}/{filePath}/{fileName}.test.{ext}"
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/MsDiala/math-series/pull/1

the pull req for the branch
Empty file removed math_series/math_series.py
Empty file.
57 changes: 57 additions & 0 deletions math_series/series.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
def fibonacci(n): ##Function that returns value of the given index from Fibonacci sequence
'''
Given an integer value n, this function returns the nth value of the Fibonacci Numbers.
'''
if isinstance(n, str):
#The isinstance() function returns True if the specified object
#is of the specified type, otherwise False.
raise TypeError("n must be an integer greater than or equal to 0.") # The raise keyword is used to raise an exception.
elif n < 0:
prompt = "n must be an integer greater than or equal to 0."
return prompt
elif n == 0:
fibonacciOfN = 0
return fibonacciOfN
elif n == 1 or n == 2:
fibonacciOfN = 1
return fibonacciOfN
elif n > 2:
fibonacciOfN = fibonacci(n-1) + fibonacci(n-2)
return fibonacciOfN


def lucas(n): ###Function that returns value of the given index from Lucas sequence
'''
Given an integer value n, this function returns the nth value of the Lucas Numbers.
'''
if n < 0:
prompt = "n must be an integer greater than or equal to 0."
return prompt
elif n == 0:
lucasOfN = 2
return lucasOfN
elif n == 1:
lucasOfN = 1
return lucasOfN
elif n >= 2:
lucasOfN = lucas(n-1) + lucas(n-2)
return lucasOfN


def sum_series(n, arg1=0, arg2=1): ###Function that returns value of the given index from Custom fibonacci-like sequence
# pass
'''
Given an integer value n and two optional terms arg1 and arg2, this function returns the nth value of the user-specified Fibonacci or Lucas numbers (defaults to Fibonacci if no optional terms provarged).
'''
if n < 0:
prompt = "n must be an integer greater than or equal to 0."
return prompt
elif arg1 == 0 and arg2 == 1:
fibonacciOfN = fibonacci(n)
return fibonacciOfN
elif arg1 == 2 and arg2 == 1:
lucasOfN = lucas(n)
return lucasOfN
else:
noSum = "Sorry, that sum is not defined."
return noSum
121 changes: 120 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ python = "^3.9"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
black = {version = "^20.8b1", allow-prereleases = true}
pylint = "^2.6.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
5 changes: 0 additions & 5 deletions tests/test_math_series.py

This file was deleted.

Loading