You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I took a look at the source code and found some places to improve it and therefore increase efficiency and reduce runtime. BTW: Why is the content of the complete main.js file shifted to the right?
gcd:
to parse the arguments into integers and to check if both numbers are NaN or negative is only necessary once, at the beginning
instead of checking for negative number or zero simply use Math.abs
--> outsourcing the actual implementation of the Euclidean algorithm
--> BETTER: use imperative implementation instead of recursive
avoid loop without break-condition to avoid mistakes and infinite loops
--> use m * m <= n as loop-break-condition
--> add factors.push(n); return factors; at end
Hope i could help.
The text was updated successfully, but these errors were encountered:
I took a look at the source code and found some places to improve it and therefore increase efficiency and reduce runtime. BTW: Why is the content of the complete
main.js
file shifted to the right?gcd:
Math.abs
--> outsourcing the actual implementation of the Euclidean algorithm
--> BETTER: use imperative implementation instead of recursive
gcdExtended:
gcd
factorize:
--> use
m * m <= n
as loop-break-condition--> add
factors.push(n); return factors;
at endHope i could help.
The text was updated successfully, but these errors were encountered: