This is a java program generate pseudo-random numbers using Naor-Reingold Pseudo-Random function. Let p and l be prime numbers with l |p-1. Select an element g in Fp of multiplicative order l. Then for each n-dimensional vector a = (a1, …, an). Fa(x) = g^(a1^x1 * a2^x2 …).
Here is the source code of the Java Program to Implement Naor-Reingold Pseudo Random Function. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
//This is a java program to generate a random numbers using Naor-Reingold Psedurandom Function
import java.util.Random;
public class Naor_Reingold
{
public static void main(String args[])
{
int p=7, l=3, g=2, n=4, x;
int []a = {1,2,2,1};
int []bin = new int[4];
Random random = new Random();
System.out.println("The Random numbers are: ");
for(int i=0; i<10; i++)
{
x = random.nextInt(17);
for(int j=3; j>=0; j--)
{
bin[j] = x%2;
x/=2;
}
int mul = 1;
for(int k=0; k<4; k++)
mul *= Math.pow(a[k], bin[k]);
System.out.println(Math.pow(g, mul));
}
}
}
Output:
$ javac Naor_Reingold.java $ java Naor_Reingold The Random numbers are: 2.0 4.0 2.0 2.0 2.0 16.0 4.0 16.0 16.0 4.0
Related posts:
Merging Two Maps with Java 8
Một số từ khóa trong Java
Java Program to Give an Implementation of the Traditional Chinese Postman Problem
Loại bỏ các phần tử trùng trong một ArrayList như thế nào?
Tính kế thừa (Inheritance) trong java
Java Copy Constructor
Overview of Spring Boot Dev Tools
Java Program to Perform the Shaker Sort
Một số nguyên tắc, định luật trong lập trình
Most commonly used String methods in Java
Java Program to Find Path Between Two Nodes in a Graph
Spring WebFlux Filters
Java Program to Implement Variable length array
Guide to Escaping Characters in Java RegExps
Remove the First Element from a List
Java Program to Implement Sorted Circularly Singly Linked List
Java Program to Implement Max-Flow Min-Cut Theorem
Java Program to Check for balanced parenthesis by using Stacks
Java CyclicBarrier vs CountDownLatch
Setting a Request Timeout for a Spring REST API
How to Change the Default Port in Spring Boot
Java Program to Generate Random Numbers Using Multiply with Carry Method
Remove All Occurrences of a Specific Value from a List
The DAO with JPA and Spring
Sorting Query Results with Spring Data
Java Program to Implement Slicker Algorithm that avoids Triangulation to Find Area of a Polygon
Java Program to Implement Cartesian Tree
Dockerizing a Spring Boot Application
Java Program to Implement Ternary Tree
Java Program to Find a Good Feedback Vertex Set
Guava – Join and Split Collections
A Guide to Concurrent Queues in Java