Gonna cite wikipedia as it is what I based my algo off