Problem 44370. Octoberfest festival
A group of students decided to visit Octoberfest festival. First they ordered one beer, then after half-hour they taken one more, after one more half-hour they ordered two more beers like sum of previous two times. Then after having spend a good time and anoter half an hour they ordered three beers. The situation went on. Task: calculate how many beers they ordered after n half-hours for given n - number of half-hours.
Example:
n=1 result will be 2;
n=2 result will be 4.
Solution Stats
Problem Comments
-
7 Comments
The problem and test cases are consistent.
At time zero they order one beer. After 30 minutes they order one more beer. So, within half an hour they've ordered two beers.
After another 30 minutes they order the sum of the previous two orders, which is two beers (1+1=2). So, within two half-hours they've ordered four beers. After yet another 30 minutes they again order the sum of the previous two orders, which is now three beers (1+2=3). So, within three half-hours they've ordered seven beers. And they continue on, thenceforth always ordering the sum of the preceding two orders. For example, the following order would be five beers (2+3=5), so the cumulative total after four half-hours would be twelve beers.
This is a very famous sequence, albeit in a different context.
(It would have been better to have more text cases, though.)
Good problem, but you could add more test cases, like n = 0, which should be 1. And a higher n, 144, which should be much greater than 2 billion beers (after 3 days straight at Octoberfest, wow). Unfortunately, It is impossible to calculate the beer for all 16 to 18 days within machine precision.
nice
Solution Comments
Show commentsGroup

Magic Numbers IV
- 20 Problems
- 24 Finishers
- Bouncy numbers
- It's going down. We're finding simbers!
- Euler–Mascheroni constant
- Hilbert numbers
- Pseudo Square Root (Inspired by Project Euler 266)
- Counting the Grand Primes
- Nth roots of unity
- Find Pseudo-Cyclic Number
- Lah Numbers
- Polar Form Complex Number Entry
- Give me Hamming on five, hold the mayo
- calculate PI without using pi function
- How brilliant are you?
- I'm going to enjoy watching you calculate, Mr Anderson
- Find two triangular numbers whose sum is input.
- Consecutive Powers
- Goldbach's marginal conjecture - Write integer as sum of three primes
- How many unique Pythagorean triples?
- Approximate e
- Amicable numbers
Problem Recent Solvers477
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!