Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

primeFactors always return the same array #13

Closed
yukulele opened this issue Jun 23, 2022 · 2 comments
Closed

primeFactors always return the same array #13

yukulele opened this issue Jun 23, 2022 · 2 comments
Assignees
Labels
triage To be investigated

Comments

@yukulele
Copy link

Steps to reproduce

import { primeFactors } from './primeFactors'
const a = primeFactors(7)
console.log(a)
const b = primeFactors(222)
console.log(b)
console.log(a)

Actual behavior

[ 7 ]
[ 2, 3, 37 ]
[ 2, 3, 37 ]

Expected behavior

[ 7 ]
[ 2, 3, 37 ]
[ 7 ]
@yukulele yukulele added the triage To be investigated label Jun 23, 2022
@vitaly-t
Copy link
Owner

vitaly-t commented Jun 24, 2022

Thank you for reporting the issue, I will try to make time to look into it ;)

For the time being, you can work around it by cloning the array:

const a = [...primeFactors(7)];

@vitaly-t
Copy link
Owner

Fixed in version 0.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage To be investigated
Projects
None yet
Development

No branches or pull requests

2 participants