Categories
Programming

Function to generate the Fibonacci numbers.

Write a function to print the Fibonacci numbers.

The fibonacci sequence is a set of numbers formed by

F_n = F_{n-1} + F_{n-2},\!\,

with seed values

F_0 = 0 \quad\text{and}\quad F_1 = 1.

This generates the numbers using the following set of rules….

 \begin{align} 0 + 1 &= 1 \\ 1 + 1 &= 2 \\ 1 + 2 &= 3 \\ 2 + 3 &= 5 \\ 3 + 5 &= 8 \\ 5 + 8 &= 13 \\  &\;\vdots \end{align}

So the fibonacci sequence is 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,…

Categories
Algrebra Math Problems

Grazing problem

This is basic “interview algebra” – it is *not* a differential equations problem. I suspect the whole trick to this problem is making you *think* you are supposed to be setting up and solving a differential equation – so basically if you are getting asked a problem like this in an interview the interviewer is trying to see if you make things hard for yourself under pressure. Useful information to know for both parties.

Grass grows in a field at some rate r, where r is the units of grass grown per day. It is known that if 10 sheep are turned out in the field, the grass will be gone in 20 days. On the other hand, if 15 sheep are turned out in the field, the grass will be gone in 10 days. If 25 sheep are turned out in the field, when will the grass be gone? ( Another Microsoft question from http://vijay.techi.googlepages.com/puzzles).

So I ran across pretty much this exact same problem on pg 36 of Mathematical Recreations from 1907 and they attributed the problem to Isaac Newton.

Grazing rate problem
Grazing rate problem
Categories
Algrebra

Men crossing a desert

An explorer wishes to cross a barren desert that requires 6 days to cross, but one man can only carry enough food for 4 days. What is the fewest number of other men required to help carry enough food for him to cross, the constraint is that each man should survive? (One of the Microsoft questions from http://vijay.techi.googlepages.com/puzzles).

Categories
Puzzles

Overlapping clock hands

Imagine an analog clock set to 12 o’clock. Note that the hour and minute hands overlap. How many times each day do both the hour and minute hands overlap? How would you determine the exact times of the day that this occurs? (Got this problem off of http://vijay.techi.googlepages.com/puzzles but it was one of their Microsoft questions).

Categories
Weighing Problems

8 counterfeit coins, a scale, and two weighings

Eight eggs look identical except one is lighter. How can you weigh only 2 times on a balance scale to find out which one is lighter?

Categories
Puzzles

3 Measuring glasses.

There are 3 glasses. The biggest one can hold 24 ounces. The medium one can hold 11 ounces and the smallest one can hold 5 ounces. Now you have 24 ounces of soft drink in the largest glass. Can you use just these 3 glasses to make the largest glass contain 12 ounces of soft drink by pouring soft drink from one glass to another?

Categories
Weighing Problems

Weights of pills

You have 5 jars of pills. Each pill weighs 10 gram, except for contaminated pills contained in one jar, where each pill weighs 9 gm. Given a scale, how could you tell which jar had the contaminated pills in just one measurement?

Categories
Puzzles

Two jars of marbles one red and one blue – how can you maximize the chances of a red marble being picked?

You have two jars, 50 red marbles and 50 blue marbles. A jar will be picked at random, and then a marble will be picked from the jar. Placing all of the marbles in the jars, how can you maximize the chances of a red marble being picked? What are the exact odds of getting a red marble using your scheme?

 

as

Categories
Puzzles

Two water pail problems – Given a 5L and 3L containers measure 4L of fluid.

 The problem: If you had an infinite supply of water and a 5 quart and 3 quart pail, how would you measure exactly 4 quarts?

  1. Fill the 5L container
  2. Empty the 5L container into the 3L container.
  3. Empty the 3L container and then re-fill it with the 2L left in the 5L container.
  4. Refile the 5L container.
  5. Pour the five  liter container int the 3L container which already contains 2L.

Now the 5L container contains (5 – (3-2))L or the desired 4L

Categories
Algrebra Math

Proof of the quadratic equation

This is more along the lines of proving what I know. Kind of struck me that this is a visual representation of something you see in martial arts all the time. You can use techniques you know to force your way through to a valid but un-elegant solution or you can do it elegantly. Both are technically correct but it is pretty obvious which way you should be solving the problem. *ugh* I think I am not up to reviewing though freshman year of high school. Who would have thought I forgot so much. 

Proof of the quadratic equation
Proof of the quadratic equation