summaryrefslogtreecommitdiffstats
path: root/hack/rnd.c
blob: 33e96c221cae356b40ef57efce1788d6a8c9c35a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*	$NetBSD: rnd.c,v 1.4 1997/10/19 16:59:39 christos Exp $	*/

#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: rnd.c,v 1.4 1997/10/19 16:59:39 christos Exp $");
#endif				/* not lint */

#include <stdlib.h>
#include "hack.h"
#include "extern.h"

#define RND(x)	((random()>>3) % x)

int
rn1(x, y)
	int             x, y;
{
	return (RND(x) + y);
}

int
rn2(x)
	int             x;
{
	return (RND(x));
}

int
rnd(x)
	int             x;
{
	return (RND(x) + 1);
}

int
d(n, x)
	int             n, x;
{
	int tmp = n;

	while (n--)
		tmp += RND(x);
	return (tmp);
}