Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c2231db
Create a factors.js
zhiwei8 Aug 8, 2022
094f41c
Update CI.yml
zhiwei8 Aug 27, 2022
613ce07
Update factors.js(v1)
zhiwei8 Aug 27, 2022
9e30e23
Merge branch 'master' into master
zhiwei8 Aug 27, 2022
a4bdee4
Create factors.test.js
zhiwei8 Aug 27, 2022
41038d3
Update data-structure images.
trekhleb Aug 27, 2022
8c7950a
Update data-structure images.
trekhleb Aug 27, 2022
a81c0bd
Update data-structure images.
trekhleb Aug 27, 2022
6914c65
Update data-structure images.
trekhleb Aug 27, 2022
f9b558b
Update data-structure images.
trekhleb Aug 27, 2022
1d02cd6
Update data-structure images.
trekhleb Aug 29, 2022
4d2d718
Add a link to minimalistic data structure sketches. (#933)
trekhleb Aug 30, 2022
865d743
Update factors.js
zhiwei8 Aug 31, 2022
19d8c9a
Update factors.test.js
zhiwei8 Aug 31, 2022
bbb2bdc
Update CI.yml
zhiwei8 Aug 31, 2022
83353b1
Update CI.yml
zhiwei8 Aug 31, 2022
ff774d8
Merge pull request #1 from zhiwei8/patch-1
zhiwei8 Aug 31, 2022
3a09ae3
Update factors.js
zhiwei8 Aug 31, 2022
11aafdc
Update factors.js
zhiwei8 Aug 31, 2022
82a0824
Update factors.js
zhiwei8 Aug 31, 2022
f9e2049
Merge branch 'master' into test
GohJunLe Aug 31, 2022
f862012
Update factors.js
zhiwei8 Sep 1, 2022
955f9aa
README.md
zhiwei8 Sep 1, 2022
4e4ea82
Update README.md
zhiwei8 Sep 1, 2022
bdc97ac
Update README.md
zhiwei8 Sep 2, 2022
95624e7
Update factors.js
zhiwei8 Sep 2, 2022
2094ecd
Update src/algorithms/math/factors/factors.js
zhiwei8 Sep 2, 2022
97292db
Update src/algorithms/math/factors/factors.js
zhiwei8 Sep 2, 2022
ff3d147
Update src/algorithms/math/factors/factors.js
zhiwei8 Sep 2, 2022
1634a40
Update src/algorithms/math/factors/factors.js
zhiwei8 Sep 2, 2022
964c5d5
Update src/algorithms/math/factors/factors.js
zhiwei8 Sep 2, 2022
ed29843
Update src/algorithms/math/factors/factors.js
zhiwei8 Sep 3, 2022
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ npm test -- 'playground'

### References

[▶ Data Structures and Algorithms on YouTube](https://www.youtube.com/playlist?list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
- [▶ Data Structures and Algorithms on YouTube](https://www.youtube.com/playlist?list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
- [✍🏻 Data Structure Sketches](https://okso.app/showcase/data-structures)

### Big O Notation

Expand Down
21 changes: 21 additions & 0 deletions src/algorithms/math/factors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# factor


What is factor?

Factor is a term in multiplication for a whole number by which a larger whole number can be divided.
A factor is a number that divides another number, leaving no remainder.
a factor is a number that divides another number without leaving any remainder.
In contrast, a multiple is a number that, when divided a certain of times by another number, no remainder is left.
To be the factors of a number, the factor number should exactly divide the number (with 0 remainder).
There are two methods of finding factors: multiplication and division.
In addition, rules of divisibility may also be used.


## References

https://en.wikipedia.org/wiki/Factor#Mathematics

https://www.storyofmathematics.com/factors-multiples/

https://www.splashlearn.com/math-vocabulary/multiplication/factor
15 changes: 15 additions & 0 deletions src/algorithms/math/factors/_test_/factors.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { factors } from '../factors';

describe('factors', () => {
it('should find factors', () => {
expect(factors(1)).toEqual([1]);
expect(factors(2)).toEqual([1, 2]);
expect(factors(3)).toEqual([1, 3]);
expect(factors(4)).toEqual([1, 2, 4]);
expect(factors(5)).toEqual([1, 5]);
expect(factors(14)).toEqual([1, 2, 7, 14]);
expect(factors(40)).toEqual([1, 2, 4, 5, 8, 10, 20, 40]);
expect(factors(54)).toEqual([1, 2, 3, 6, 9, 18, 27, 54]);
expect(factors(100)).toEqual([1, 2, 4, 5, 10, 20, 25, 50, 100]);
});
});
16 changes: 16 additions & 0 deletions src/algorithms/math/factors/factors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Finds the factor of a number.
*/
export default function printFactors(x) {
console.log('The factors of', x, 'are:');
// looping
for (let i = 1; i <= x; i++) {
if (x % i === 0) {
console.log(i);
}
}
}

// get the input from the user
const num = prompt('Enter a positive integer: ');
printFactors(num);
Binary file modified src/data-structures/heap/images/array-representation.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/data-structures/heap/images/max-heap.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/data-structures/heap/images/min-heap.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/data-structures/queue/images/queue.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/data-structures/stack/images/stack.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/data-structures/tree/images/tree.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/data-structures/trie/images/trie.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.