Skip to content

Commit 1f71634

Browse files
committed
first init
0 parents  commit 1f71634

File tree

6 files changed

+244
-0
lines changed

6 files changed

+244
-0
lines changed

.gitignore

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
.jpeg
2+
.png
3+
.jpg
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
*$py.class
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
pip-wheel-metadata/
27+
share/python-wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
MANIFEST
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.nox/
47+
.coverage
48+
.coverage.*
49+
.cache
50+
nosetests.xml
51+
coverage.xml
52+
*.cover
53+
.hypothesis/
54+
.pytest_cache/
55+
56+
# Translations
57+
*.mo
58+
*.pot
59+
60+
# Django stuff:
61+
*.log
62+
local_settings.py
63+
db.sqlite3
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
.python-version
87+
88+
# pipenv
89+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
90+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
91+
# having no cross-platform support, pipenv may install dependencies that don’t work, or not
92+
# install all needed dependencies.
93+
#Pipfile.lock
94+
95+
# celery beat schedule file
96+
celerybeat-schedule
97+
98+
# SageMath parsed files
99+
*.sage.py
100+
101+
# Environments
102+
.env
103+
.venv
104+
env/
105+
venv/
106+
ENV/
107+
env.bak/
108+
venv.bak/
109+
110+
# Spyder project settings
111+
.spyderproject
112+
.spyproject
113+
114+
# Rope project settings
115+
.ropeproject
116+
117+
# mkdocs documentation
118+
/site
119+
120+
# mypy
121+
.mypy_cache/
122+
.dmypy.json
123+
dmypy.json
124+
125+
# Pyre type checker
126+
.pyre/

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) 2019 Andrew Li
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.
20+
21+
Do not copy for your homework or labwork!!

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Quick Algorithms or Formulas
2+
3+
## About
4+
5+
This is a collection of algorithms and formulas written in different programing languages
6+
7+
8+
9+
## How to Use
10+
11+
For MacOS or Linux:
12+
13+
```shell
14+
python3 name_of_program.py
15+
```
16+
17+
For Windows:
18+
19+
```powershell
20+
py name_of_program.py
21+
```
22+
23+
24+
25+
## Licence
26+
27+
The rules for copy and distributing this project licence are
28+
outlined in the licence.txt file.
29+
30+
This project is under an MIT licence
31+
32+
33+
34+
## Included:
35+
36+
* gcd - greatest common divisor
37+
38+
* lcd - lowest common denominator

python/gcd.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
""""
2+
gcd (greatest common divisor) by Andrew Li
3+
"""
4+
5+
6+
def gcd(int1, int2):
7+
if int2 == 0:
8+
return int(int1)
9+
return gcd(int1, int1 % int2)

python/lcd.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
""""
2+
lcd (lowest common denominator) by Andrew Li
3+
"""
4+
from gcd import gcd
5+
6+
def lcd(gcd, int1, int2):
7+
return int((int1*int2)/gcd)
8+
9+
def lcd_no_gcd(int1, int2):
10+
return int((int1*int2)/gcd(int1,int2))

typescript/is_prime.ts

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// chose any number
2+
let number: number = 146192364271;
3+
4+
// let number: any = process.openStdin();
5+
6+
function isPrime(number) {
7+
// is the number prime
8+
9+
// if 1, 0, or negative return an error
10+
if (number <= 1) {
11+
return 'The number cannot be below or equal to 1';
12+
} else {
13+
// if less than prime, it is prime, otherwise,
14+
// check if it is even, ends in 5 or divisible by 3 it is not prime
15+
if (number <= 5 && number != 4) {
16+
return 'prime';
17+
} else if (number % 10 % 2 === 0 || number % 10 === 5) {
18+
return 'not prime';
19+
} else if (number % 3 === 0) {
20+
return 'not prime';
21+
} else {
22+
// for i starting at 7 and incrementing a 2
23+
for (let i: number = 7; i >= number ** .5; i+=2) {
24+
// if multiple of 3, continue otherwise
25+
// if it is module the index, it is not prime
26+
if (i % 10 % 3 === 0) {
27+
continue;
28+
} else if (number % i === 0) {
29+
return 'not prime';
30+
}
31+
}
32+
33+
// if not flag, it is prime
34+
return 'prime';
35+
}
36+
}
37+
}
38+
39+
// calls is prime
40+
console.log(isPrime(number));

0 commit comments

Comments
 (0)