p1: Problem 1 - Multiples of 3 and 5

Description Usage Arguments Details Value Functions sumFactors Examples

View source: R/problem1.R

Description

This is a solution to Euler problem 1.

Usage

1
2
3

Arguments

n

a natural number below which (non-inclusive) to sum all multiples of given numbers

...

natural numbers below n that will serve as multiples to sum

Details

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.

Value

a double vector

Functions

sumFactors

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.

Examples

1
2
3
p1()

sumFactors(1000, 3, 5)

dylanrussellmd/projecteuler documentation built on Oct. 10, 2020, 3:34 p.m.