Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 1.71 KB

README.md

File metadata and controls

65 lines (44 loc) · 1.71 KB

1349800

Instructions

Please edit the pages for the three questions in-place. Provide the answer to each question, plus the code used to solve it. Any programming language may be used, any libraries, etc. If using an external resource, please credit it.

Large summation

The multiples of 5 are: 5, 10, 15, 20, 25, 30, 35...

The multiples of 7 are: 7, 14, 21, 28, 35...

If we add the multiples of 5 and 7 that are less than 40, we get:

5 + 7 + 10 + 14 + 15 + 20 + 21 + 25 + 28 + 30 + 35 = 210

What is the sum of the multiples of 5 and 7 that are less than 1 million?

Recursively defined sequence

Let the function f(n) return (n / 2) if n is even, and (1 + 3 * n) if n is odd.

Examples: • f(1) = 4 • f(2) = 1 • f(3) = 10 • f(4) = 2

The function a(n) returns a sequence of numbers. That sequence is determined as follows: • The initial element is n. • Each subsequent element is the function f applied to the previous element. • The sequence terminates after it evaluates to 1.

Example: a(3) returns[3, 10, 5, 16, 8, 4, 2, 1] • n=3, so that is the first element. • We apply f to the previous element. f(3) is 10, so that is the second element. • We continue: f(10) = 5, f(5) = 16, f(16) = 8, f(8) = 4, f(2) = 1. • We terminate after the sequence reaches 1.

The sum of the elements returned by a(3) is 3 + 10 + 5 + 16 + 8 + 4 + 2 + 1 = 49.

What is the sum of the elements returned by a(6171)?

Leap day

February 29th is called the "leap day."

February 29th, 1940 was a Thursday. February 29th, 2000 was a Tuesday.

Between 1900 and 2000 (inclusive), how many leap days fell on each day of the week?

Weekday Number of leap days Sunday Monday Tuesday Wednesday Thursday Friday Saturday