Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function splitSum(sum, splits){
- let result = [];
- let a = parseInt(sum)/parseInt(splits)
- for(let i = 0; i<parseInt(splits); i++) {
- result[i] = i%2 ? Math.round( (a+(a/(i+3)))/10 )*10 : Math.round( (a-(a/(i+2)))/10) *10
- };
- var all_sum = 0;
- result.map(v => all_sum +=v)
- result[result.length - 1] += Math.round(parseInt(all_sum) - parseInt(sum))
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment