<script> function num(a) { var n = 0, l = Math.round(a / 2); for (var i = 2; i <= l; i++) if (a % i == 0) n += i; return n }; document.write(num(6)) </script>