Project: Magic or Math
There are many variations on the magic trick where the magician asks the audience member to think of a number. He then instructs the audience member to perform a number of math operations on that number that seem to generate a random result, however the magician is always able to miraculously guesses the correct result.
- Think of a number
- Double it
- Add 10
- Halve it
- Subtract your original number
- The answer is 5
Write a program that defines an integer variable with the original value randomly generated between 1 and 100. Print the value of the variable after each stage of the trick so we can see how the trick progresses. Run the program a number of times. Is the answer always 5?
Output
$ rustc MagicOrMath.rs
error[E0425]: cannot find function `irandom` in this scope
--> MagicOrMath.rs:8:24
|
8 | let mut value:isize = irandom(100);
| ^^^^^^^ not found in this scope
error: aborting due to previous error
For more information about this error, try `rustc --explain E0425`.
$ rustc MagicOrMath.rs
error[E0425]: cannot find function `irandom` in this scope
--> MagicOrMath.rs:8:24
|
8 | let mut value:isize = irandom(100);
| ^^^^^^^ not found in this scope
error: aborting due to previous error
For more information about this error, try `rustc --explain E0425`.
$ rustc MagicOrMath.rs
error[E0425]: cannot find function `irandom` in this scope
--> MagicOrMath.rs:8:24
|
8 | let mut value:isize = irandom(100);
| ^^^^^^^ not found in this scope
error: aborting due to previous error
For more information about this error, try `rustc --explain E0425`.