| CS 242, Section 002 | Sonoma State University | Spring, 2026 |
|
Discrete Structures for Computer Science
|
||
|
Instructor: Henry M. Walker
Lecturer, Sonoma State University | ||
Notes:
A Mathematics Inequality: Use mathematical induction to prove that, given x > 0, (1 + x)n ≥ 1 + nx for all n ≥ 0.
Random Number Generators in C/C++/Python
The Linux on-line manual states, "The random() function
[defined in the <stdlib.h> library]
... returns successive pseudo-random numbers in the range from 0 to
(2**31)−1." That is, each time random() is called, it
returns a different random number between 0 and
231-1. (More information likely is available from a
Linux terminal window by typing man random.)
Similarly, within Python, the random module,
the randint (a, b) function returns a pseudo-random
integer N, such
that a <= N <= b.
Pragmatically, it turns out that this function can be extremely
useful when programming simulations and other applications.
Within the context of C/C++ and within Python, documentation identifies the random() as a function. With your understanding of a C/C++ or Python, does a random number generater fit within the definition of a "function" for that programming language? That is, what is your understanding of a "function" in a programming language, and does a random number generator satisfy that definition? Explain briefly.
Turning to formal mathematics, does a random number generator, such as random() in C/C++ or randint(a,b) in Python satisfy the definition of a mathematical function? As in Part a, explain briefly.
Return Values from Functions in C/C++/Python:
In C/C++/Python, functions are sometimes described as a block of
code, or a set of instructions that perform a specified task.
Also, although functions may return a value (with
a return statement, this capability is optional.
Within the framework of formal mathematics, does a function with no return value satisfy the definition of a mathematical function? Explain briefly.
|
created October 25, 2025 revised October-November, 2025 |
|
| For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |