1 views

Original Title: Lcm & Clcm Printout

Uploaded by Mahesh Abnave

- Display Source for Correction
- Mandel Bort
- ymwputqutyuutpokadoqr.txt
- Pertemuan 5 6 dan 7
- COMP3040-02 Data Structures Assignment 1 PART 4
- mse5
- Lec2-CommonAlgo
- 04 Demo Earliest Finish Time First
- angularjs-provider-cheat-sheet.pdf
- Code
- The Ring programming language version 1.5.2 book - Part 154 of 181
- program.cs
- Report Alv Total
- Zsd Compartive Repot Ganesh
- Calendar Month Payroll Period End Dates Always on 30th of Month
- Calculator Code
- 4 Solution
- PMRC
- utl_file
- Java Assignment

You are on page 1of 4

Code

package rngenerationsdemo;

import java.io.*;

/**

* @author Mahesh

*/

public class Main {

int c, k, choice;

while (true) {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

System.out.println(" Generating pseudo random numbers using LCM &

CLCM methods");

System.out.println("Which method to use:");

System.out.println("1. LCM");

System.out.println("2. CLCM");

System.out.println("3. Exit");

System.out.println("----------------------------");

System.out.print("Enter choice:");

choice = Integer.parseInt(br.readLine());

switch (choice) {

case 1: {

System.out.print("How many random numbers to generate: ");

k = Integer.parseInt(br.readLine());

int m, a;

double[] X = new double[k+1];

double[] R = new double[k];

System.out.println("Enter input");

System.out.print("Seed (Xo): ");

X[0] = Double.parseDouble(br.readLine());

System.out.print("Multiplier (a):");

a = Integer.parseInt(br.readLine());

System.out.print("Modulus (m):");

m = Integer.parseInt(br.readLine());

System.out.print("Increment (c):");

c = Integer.parseInt(br.readLine());

X[i + 1] = (a * X[i] + c) % m;

}

R[j-1] = X[j] / m;

System.out.println("Random number " + j + ": " + R[j-1]);

}

break;

}

case 2: {

System.out.print("How many random numbers to generate: ");

k = Integer.parseInt(br.readLine());

int m[] = new int[k];

double[][] Xig = new double[k + 1][k]; //individual generator

double[] Xcg = new double[k]; //combined generator

double[] R = new double[k];

System.out.println("Enter input");

System.out.println("Seeds for generators: ");

for (int i = 0; i < k; i++) { //accepting seed values X10,X20,

X30

System.out.print(" X" + i + "0: ");

Xig[0][i] = Double.parseDouble(br.readLine());

}

System.out.println("Multipliers:");

for (int i = 0; i < k; i++) {

System.out.print(" a" + i + ":");

a[i] = Integer.parseInt(br.readLine());

}

System.out.println("Moduli:");

for (int i = 0; i < k; i++) {

System.out.print(" m" + i + ":");

m[i] = Integer.parseInt(br.readLine());

}

System.out.print("Increment:");

c = Integer.parseInt(br.readLine());

for (int i = 0; i < k; i++) {

for (int j = 0; j < k; j++) {

Xig[i + 1][j] = (a[j] * Xig[i][j] + c) % m[j];

}

}

double Xtemp; //Xtemp is the sum term in Xcg

System.out.println();

for (int i = 1; i <= k; i++) {

Xtemp=0;

for (int j = 0; j < k; j++) {

Xtemp = Xtemp + Math.pow(-1, j) * Xig[i][j];

}

Xcg[i-1] = Xtemp % (m[0] - 1);

if (Xcg[i-1] > 0) {

R[i - 1] = Xcg[i-1] / m[0];

} else if (Xcg[i-1] == 0) {

R[i - 1] = (m[0] - 1) / m[0];

}

System.out.println("Random number " + i + ": " + R[i - 1]);

}

break;

}

case 3: {

System.out.println("\nExiting...");

System.exit(0);

break;

}

}

}

}

}

Output

Gaenerating pseudo random numbers using LCM & CLCM method

Which method to use:

1. LCM

2. CLCM

3. Exit

----------------------------

Enter choice:1

How many random numbers to generate: 3

Enter input

Seed (Xo): 37

Multiplier (a):7

Modulus (m):100

Increment (c):29

Random number 1: 0.88

Random number 2: 0.45

Random number 3: 0.44

Which method to use:

1. LCM

2. CLCM

3. Exit

----------------------------

Enter choice:2

How many random numbers to generate: 3

Enter input

Seeds for generators:

X00: 100

X10: 300

X20: 500

Multipliers:

a0:157

a1:146

a2:142

Moduli:

m0:32363

m1:31727

m2:31657

Increment:0

Random number 2: 0.08383030003398943

Random number 3: 0.05144764082439823

Which method to use:

1. LCM

2. CLCM

3. Exit

----------------------------

Enter choice:3

Exiting...

- Display Source for CorrectionUploaded byAdi SAP
- Mandel BortUploaded bycarfra_789
- ymwputqutyuutpokadoqr.txtUploaded byJuan Arnao Perez
- Pertemuan 5 6 dan 7Uploaded bynabila z
- COMP3040-02 Data Structures Assignment 1 PART 4Uploaded byJhonnatan Romay
- mse5Uploaded byBea Oro
- Lec2-CommonAlgoUploaded byAl Muzammil Muhamad
- 04 Demo Earliest Finish Time FirstUploaded byJohn Le Tourneux
- angularjs-provider-cheat-sheet.pdfUploaded byRanjit Sachin
- CodeUploaded byPrudhvidhar Reddy
- The Ring programming language version 1.5.2 book - Part 154 of 181Uploaded byMahmoud Samir Fayed
- program.csUploaded bywbnwbnwbn
- Report Alv TotalUploaded bymurilloarantes
- Zsd Compartive Repot GaneshUploaded byYellaReddy Tarigopula
- Calendar Month Payroll Period End Dates Always on 30th of MonthUploaded byMohamed Shanab
- Calculator CodeUploaded bybharat
- 4 SolutionUploaded byultravista
- PMRCUploaded bySiddhesh Pednekar
- utl_fileUploaded bySubhash Chandra
- Java AssignmentUploaded byMarcia Johnson
- מונחה עצמים- תרגול 4Uploaded byRon
- Implement Circular Link List Using Templates. Include Function for Insertion, Deletion, Search of a No., Reverse the List.Uploaded bysristisagar
- 2013 Winter Midterm AMUploaded byKenny
- statemachine hUploaded byapi-316663272
- knn programUploaded byganesh
- CNT ALVUploaded bySerkanKeleş
- Www.minich.com Education Racc Visualbasic Cis230ch5 Frmcis230ch5demo2form1Uploaded byMohammad Ali
- vcUploaded bysristisagar
- OOpsQuiz2Uploaded byVinod Shanker Shringi
- Grid Radio Button FunctionalityUploaded byVijay Bhalerao

- Discrete Fourier TransformUploaded byMahesh Abnave
- PCI ExpressUploaded byMahesh Abnave
- Git CommandsUploaded byMahesh Abnave
- Game API.docxUploaded byMahesh Abnave
- Chipset ArchitectureUploaded byMahesh Abnave
- Chapter 04 Image e Nhanc SpatUploaded byMahesh Abnave
- Different types of operating systemsUploaded byMahesh Abnave
- Vector SpacesUploaded byMahesh Abnave
- Expansion SlotsUploaded byMahesh Abnave
- DSIP Case StudiesUploaded byMahesh Abnave
- Wireless LAN BasicsUploaded byMahesh Abnave
- Functional Dependencies & NormalisationUploaded byMahesh Abnave
- Digital Image ProcessingUploaded byMahesh Abnave
- Multi Sever Queue PrintoutUploaded byMahesh Abnave
- Inventory SystemUploaded byMahesh Abnave
- Clocked Synchronous State MachinesUploaded byMahesh Abnave
- Discrete Image ProcessingUploaded byMahesh Abnave
- Datastructures ProgramsUploaded byMahesh Abnave
- Operational AmplifierUploaded byMahesh Abnave
- Operational Amplifier Basics by Harry LythallUploaded byMahesh Abnave
- NormalisationUploaded byMahesh Abnave
- 945G Chipeset detailsUploaded byMahesh Abnave
- 915G Chipset detailsUploaded byMahesh Abnave
- Read and Write Heads and Head Actuator Mechanisms of Hard disksUploaded byMahesh Abnave
- 04 04 Intuition for Regularization 06-59Uploaded byMahesh Abnave
- 04 04 Data Dimensions 3-08Uploaded byMahesh Abnave
- Turing Encoding(ITCS 7)Uploaded byMahesh Abnave
- Anand Presentation150813-03 ConvertedUploaded byMahesh Abnave

- DBMS-SyllabusUploaded bySangeetha Prakash
- Resume and Coversheet (1)Uploaded byHarrison Gould
- Export Jtable Data to PDFUploaded byVictor
- Vivado TutorialUploaded byEmmanuel Bautista-Dizon
- MCA_2015Uploaded byGagan Bansal
- Creating Secured PDF DocumentsUploaded byAugustus Caesar
- AMD APP SDK Installation NotesUploaded byLuis Riv
- Operating System Vocabulary WordsUploaded bybloodtype
- A guide on eIDAS 910/2014Uploaded byxyzmo SIGNificant
- GIS StandardsUploaded bySantosh N. Patil
- Application of Adomian Decomposition method to seepage flow derivatives in porous media using fractional calculusUploaded byIJSRP ORG
- Mq90.AdministerUploaded byAvinash
- Watson Developer Certification - Study AidUploaded byAniruddha Ray
- Mapping of the George C. Yount Pioneer CemeteryUploaded byDenise
- Setting Up a Chaincoin Masternode - Draft v.04Uploaded byKev Bot
- SeeAll: Interactive System to Support Competence AssessmentUploaded byValkiria Venancio
- alstom_succes.pdfUploaded byIsmael Ahmed
- Useful QueryUploaded bysanketsinha
- vLAN SwitchingUploaded byapi-3728377
- the_importance_of_operationaUploaded bysam_sush
- Diagnostic SINUMERIK 802Uploaded byAntonijo Smrdelj
- Merlins Ecuflash Evo 7-8-9 Tuning Guide-V1.7aUploaded byLevi Little
- Android Platform PPTUploaded byAditya Kumar
- Enforcer 32-WE APP V10-Installation Manual-1Uploaded byPal Istvan
- 7210 SAS-X Installation GuideUploaded bynelusabie
- Office 365 Admin GuideUploaded byNetSquared
- Safety System WorkshopUploaded bykiomes
- SAP FSCM Sample Resume 2Uploaded byASHOKA GOWDA
- Digital Assett MgmtUploaded byadevadason
- gencyberUploaded byapi-282837002