# Khan/khan-exercises

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
87 lines (78 sloc) 4.17 KB
 Probability 1
randFromArray(["bag", "jar", "box", "goblet"]) randFromArray(["marble", "ball", "jelly bean"]) randRange(3, 11) randRange(3, 11) randRange(3, 11) REDMAR + GREENMAR + BLUEMAR rand(2) === 0 randFromArray([["red", REDMAR], ["green", GREENMAR], ["blue", BLUEMAR]]) NOT ? TOTAL - CHOSEN_NUMBER : CHOSEN_NUMBER

A CONTAINER contains REDMAR red MARBLEs, GREENMAR green MARBLEs, and BLUEMAR blue MARBLEs.

If a MARBLE is randomly chosen, what is the probability that it is not CHOSEN_COLOR?

NUMBER / TOTAL

There are REDMAR + GREENMAR + BLUEMAR = TOTAL MARBLEs in the CONTAINER.

There are CHOSEN_NUMBER CHOSEN_COLOR MARBLEs. That means TOTAL - CHOSEN_NUMBER = NUMBER are not CHOSEN_COLOR.

The probability is \displaystyle fractionSimplification(NUMBER, TOTAL).

randFromArray([ ["a 1", [1]], ["a 2", [2]], ["a 3", [3]], ["a 4", [4]], ["a 5", [5]], ["a 6", [6]], ["at least 2", [2, 3, 4, 5, 6]], ["at least 3", [3, 4, 5, 6]], ["at least 4", [4, 5, 6]], ["more than 2", [3, 4, 5, 6]], ["more than 3", [4, 5, 6]], ["more than 4", [5, 6]], ["less than 4", [1, 2, 3]], ["less than 5", [1, 2, 3, 4]], ["less than 6", [1, 2, 3, 4, 5]], ["even", [2, 4, 6]], ["even", [2, 4, 6]], ["odd", [1, 3, 5]], ["odd", [1, 3, 5]], ["prime", [2, 3, 5]] ]) RESULT_POSSIBLE.length

A fair six-sided die is rolled. What is the probability that the result is RESULT_DESC?

RESULT_COUNT / 6

When rolling a die, there are 6 possibilities: 1, 2, 3, 4, 5, and 6.

In this case, only 1 result is favorable: the number RESULT_POSSIBLE[0].

In this case, RESULT_COUNT results are favorable: toSentence(RESULT_POSSIBLE).

The probability is \displaystyle fractionSimplification(RESULT_COUNT, 6).