-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlowestcom.js
More file actions
60 lines (35 loc) · 743 Bytes
/
lowestcom.js
File metadata and controls
60 lines (35 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function smallestCommons(arr) {
if (arr[0] > arr[1]) {
var temp = arr[0];
arr[0] = arr[1];
arr[1] = temp;
}
var denom = arr[0];
var numer = arr[0] + 1;
var counter = numer;
while (counter <= arr[1]) {
var tempdenom = denom;
while (denom != numer) {
denom += tempdenom;
console.log('denominator = ' + denom)
while (numer < denom) {
numer += counter
console.log('numerator = ' + numer)
}
}
console.log('lowest factor up to ' + counter + ' found')
counter++;
// numer = counter;
}
console.log(denom)
}
var i = 1
while (i < 2) {
smallestCommons([1, 7]);
i++
}
/*
3,4,5,6,7,8
sequential pairs have smallest com of a*b...
above example will need smallest com of 12,20,35,
*/