Recent content by jonesrussell
-
J
Java Javascript - Reducing a number to smaller numbers
This is what I've ended up with, var n = 7; // how many partitions var pointSet = []; for (var i=0; i<n; i++) { var partition = 0; (i < n-1) ? partition = Math.floor(maxPoints / n) : partition = (maxPoints % n) + Math.floor(maxPoints / n); pointSet.unshift(partition)...- jonesrussell
- Post #12
- Forum: Programming and Computer Science
-
J
Java Javascript - Reducing a number to smaller numbers
Ah! partition = (maxPoints % n) + Math.floor(maxPoints / n);- jonesrussell
- Post #8
- Forum: Programming and Computer Science
-
J
Java Javascript - Reducing a number to smaller numbers
Yup, but [2, 2, 2, 2, 2, 2, 4] = 16- jonesrussell
- Post #7
- Forum: Programming and Computer Science
-
J
Java Javascript - Reducing a number to smaller numbers
I was actually doing my initial testing with floor() but I don't get the expected results either. Taking the same function, replacing round() with floor(), maxPoints = 18 results in [2, 2, 2, 2, 2, 2, 4]- jonesrussell
- Post #5
- Forum: Programming and Computer Science
-
J
Java Javascript - Reducing a number to smaller numbers
I'm attempting to write this as a function and am not getting my expected results: var maxPoints = 18; // partition points into an array set var n = 7; // how many partitions var pointSet = []; for (var i=0; i<n; i++) { var partition = 0; if (i < n-1) {...- jonesrussell
- Post #3
- Forum: Programming and Computer Science
-
J
Java Javascript - Reducing a number to smaller numbers
I am looking for advice on how to approach a problem. I would like to take a given number and break it into 7 parts. For example, the function call, BreakIntoSmallerNumbers(15); would return the following array: [3, 2, 2, 2, 2, 2, 2] BreakIntoSmallerNumbers(3); returns [1, 1, 1]...- jonesrussell
- Thread
- Javascript Numbers
- Replies: 11
- Forum: Programming and Computer Science