Title: #2652 - Sum Multiples - LeetCode JavaScript Solutions
Open Graph Title: #2652 - Sum Multiples - LeetCode JavaScript Solutions
X Title: #2652 - Sum Multiples - LeetCode JavaScript Solutions
Description: Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7. Return an integer d...
Open Graph Description: Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7. Return an integer d...
X Description: Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7. Return an integer d...
Keywords:
Opengraph URL: https://leetcodejavascript.com/solutions/sum-multiples
Domain: leetcodejavascript.com
{"@context":"https://schema.org","@type":"Code","url":"https://leetcodejavascript.com/solutions/sum-multiples","name":"#2652 - Sum Multiples - LeetCode JavaScript Solutions","description":"Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7. Return an integer d...","programmingLanguage":"JavaScript","codeRepository":"https://github.com/JoshCrozier/leetcode-javascript","codeSampleType":"JavaScript","text":"/**\n * @param {number} n\n * @return {number}\n */\nvar sumOfMultiples = function(n) {\n return sumDivisibleBy(3) + sumDivisibleBy(5) + sumDivisibleBy(7)\n - sumDivisibleBy(15) - sumDivisibleBy(21) - sumDivisibleBy(35)\n + sumDivisibleBy(105);\n\n function sumDivisibleBy(divisor) {\n const count = Math.floor(n / divisor);\n return divisor * count * (count + 1) / 2;\n }\n};","keywords":"LeetCode 2652, #2652 - Sum Multiples, Easy, JavaScript solution","learningResourceType":"Code","isAccessibleForFree":true,"educationalLevel":"intermediate","interactivityType":"mixed"}
| author | LeetCodeJavascript.com |
| og:type | article |
| og:image | https://leetcodejavascript.com/og-image.jpg |
| og:site_name | LeetCode JavaScript Solutions |
| twitter:card | summary_large_image |
| twitter:url | https://leetcodejavascript.com/solutions/sum-multiples |
| twitter:image | https://leetcodejavascript.com/og-image.jpg |
| twitter:creator | @joshcrozier |
| theme-color | #1f2937 |
Links:
| LeetCodeJavascript.com | https://leetcodejavascript.com/ |
| Star on GitHub | https://github.com/JoshCrozier/leetcode-javascript |
| Back to all solutions | https://leetcodejavascript.com |
| View on LeetCode | https://leetcode.com/problems/sum-multiples/ |
| View on GitHub | https://github.com/JoshCrozier/leetcode-javascript/blob/master/solutions/2652-sum-multiples.js |
| Math | https://leetcodejavascript.com/tags/math |
| Josh Crozier | https://joshcrozier.com |
Viewport: width=device-width,initial-scale=1
Robots: index, follow