---
title: "线性同余随机算法实现"
author: "ChinaEstone"
date: "2014-09-24T15:02:51Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2014-09-24T15:02:51Z"
id: 2120029
url: "https://chinaestone.iteye.com/blog/2120029"
---

```
package com.wistone.server.core;

public class MyRand {

	private int seed;

	public MyRand(int seed) {
		this.seed = seed;
	}

	public int next() {
		int next = (seed * 29 + 37) % 1000;
		seed = next;
		return next;
	}

	public static void main(String[] args) {
		MyRand rand = new MyRand(100);
		for (int i = 0; i < 100; i++) {
			System.out.println(rand.next());
		}
	}
}
```