Advertisement
31ph4n70m

Neumann's_Random_Generator.m

Dec 18th, 2019
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.46 KB | None | 0 0
  1. %% Problem : Random Number Generator ---> Mid Square Method %%
  2. %  Author  : Maniruzzaman Akash
  3.  
  4. totalNumber = input('Number of Random Numbers want to generate : ');
  5. choose = input('Enter the seed : ');
  6. disp('Total Random Numbers are : ');
  7. for i = 1:totalNumber
  8.     random = choose ^ 2;
  9.     random = random / 100; % Find the dividend
  10.     random = rem(random, 10000); % Get the reminder;
  11.     choose = random;
  12.     fprintf('%.2f ', random);
  13. end
  14. fprintf('\n');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement