A non-transitory computer readable recording medium on which a program that causes a computer to execute a random number generating method has been recorded, the program using a one-dimensional, two-state, and K-neighbor cell automaton having a plurality of cells, each cell having a state value that is 0 or 1, the state value of each cell at next time being given by a rule that depends on only the state value of the own cell and the state values of neighbor cells, the state value of each cell being updated according to the rule, the plurality of cells including inputs and outputs, the random number generating method comprising:
- when the outputs of each of the plurality of cells are fed back to inputs of other cells at the current time so as to update the state values of the plurality of cells at the next time:
- (a) for a first key stream output, shifting the output of each of the plurality of cells by a first predetermined number of cells and feeding the shifted outputs to inputs of other cells, the first predetermined number being at least two;
- (b) after the first key stream is output, changing the first predetermined number to a second predetermined number;
- and
- (c) for a second key stream output, shifting the output of each the cell by the second predetermined number of cells and feeding the shifted outputs to inputs of other cells.