Description Usage Arguments Details Value Functions sumFactors Examples
This is a solution to Euler problem 1.
1 2 3 | p1()
sumFactors(n, ...)
|
n |
a natural number below which (non-inclusive) to sum all multiples of given numbers |
... |
natural numbers below |
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
a double vector
sumFactors
: generic function for Project Euler problem #1
This function generalizes the answer to Project Euler problem #1. It is a simple way of
implementing the inclusion-exclusion principle
in R. Given any arbitrary length vector of natural numbers (...
) and a limit (n
), the sum of all multiples of the
provided numbers can be obtained.
1 2 3 | p1()
sumFactors(1000, 3, 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.