Sponsored Content
Full Discussion: Random numbers
Homework and Emergencies Homework & Coursework Questions Random numbers Post 302894460 by renegade755 on Tuesday 25th of March 2014 02:26:04 PM
Old 03-25-2014
Random numbers

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

Write a shell script that will take the sum of two random number?
Ex: Random n1 +Random n2 = result






i tries to write it but i had some dufficulties

Code:
n=$RANDOM
# display a random integer <= 200
echo $(( r %= 200 ))
# display random number between 100 and 200.
echo $(( RANDOM % 200 + 100 ))

4. Seneca college, Toronto , Canada, peter wheeler, tech 154:

Moderator's Comments:
Mod Comment edit by bakunin: Please have mercy! Instead of the 15 Pages of markup you used to create eye cancer in every reader simply use CODE-tags for your code. I cleaned that out for you, please don't make me do it again.

Last edited by bakunin; 03-25-2014 at 06:48 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Random numbers without repetition

Is anyone know some scripts to generate random number without repetition using bash; for example generate 10 different random numbers. Thanks (8 Replies)
Discussion started by: asal_email
8 Replies

2. Programming

How to set constrain on random numbers in c

Hi, I am currently trying to generate multiple random numbers in C for different variable:- die1=1+(rand()%5); die2=1+(rand()%5); die3=1+(rand()%5); die4=1+(rand()%5); But I need to contrain the total of die1, die2,die3 and die4 to be 5 as well. If i insert die1+die2+die3+die4=5, i do... (6 Replies)
Discussion started by: ahjiefreak
6 Replies

3. Shell Programming and Scripting

Random numbers from 0 to 1000

Hello All, I want to make a simple script which generate random number from 0 to 1000. and simply display it. Plz HELP!!!!!! Regards, Waqas Ahmed (2 Replies)
Discussion started by: wakhan
2 Replies

4. Shell Programming and Scripting

Random NUmbers Generation with out repetation

Hi I have the below code MAXCOUNT=10 count=1 echo echo "$MAXCOUNT random numbers:" echo "-----------------" while # Generate 10 ($MAXCOUNT) random integers. do number=$ + 1 ] "echo $number" let "count += 1" # Increment count. done But aftre executing this ... (8 Replies)
Discussion started by: lalitka
8 Replies

5. Shell Programming and Scripting

Random Numbers - Perl

Hi Guys I have a script to find Ranomd numbers. But I want to make the file to produce more random. Could u guys help me plz. In this Script I have the code that generates random in for loop and the range I have specified in my %chromlength input and out put will be like this chrno start end... (3 Replies)
Discussion started by: repinementer
3 Replies

6. Shell Programming and Scripting

Generating random numbers

Hi, I am having trouble with generating random numbers. can this be done with awk? So I have a file that looks like this: 23 30 24 40 26 34 So column1 is start and column2 is end. I want to generate 3 random #'s between start and stop: So the output will look like this: ... (9 Replies)
Discussion started by: phil_heath
9 Replies

7. Shell Programming and Scripting

Replace a random string of numbers

Hi Can someone help me with this one? I have string.. (PROC_PROC_ID == 12183) <--PID is dynamic and i want to replace the PID number with whatever PID from /opt/hpws/apache32_2/logs/httpd.pid file. i'm having problem since the PID on the string is dynamic. It may be 2-5 digits or more. ... (5 Replies)
Discussion started by: ryandegreat25
5 Replies

8. Shell Programming and Scripting

How to insert random numbers into each line?

I have a file contains thousands of lines. I want to insert n random numbers into each line at specific position. Like this: 0 22…… 1 33…… …… …… I want to insert 3 random numbers from position 2 to 4 into each line. 0 325 22…… 1 685 33…… …… …… Please use CODE tags when... (8 Replies)
Discussion started by: hhdzhu
8 Replies

9. Solaris

True random numbers in Sol10

Hi everyone I just got my hands on a T5120 running Sol10. As far as I've read, the T2 chip has a built-in hardware number generator. My question is: how can I access it to get random numbers in either C or Fortran? I'm using Sun Studio 12.4. I am currently trying to write an... (13 Replies)
Discussion started by: toguro123
13 Replies
Random(3pm)						User Contributed Perl Documentation					       Random(3pm)

NAME
Crypt::OpenSSL::RSA - RSA encoding and decoding, using the openSSL libraries Crypt::OpenSSL::Random - Routines for accessing the OpenSSL pseudo-random number generator SYNOPSIS
use Crypt::OpenSSL::Random; Crypt::OpenSSL::Random::random_seed($good_random_data); Crypt::OpenSSL::Random::random_egd("/tmp/entropy"); Crypt::OpenSSL::Random::random_status() or die "Unable to sufficiently seed the random number generator". my $ten_good_random_bytes = Crypt::OpenSSL::Random::random_bytes(10); my $ten_ok_random_bytes = Crypt::OpenSSL::Random::random_pseudo_bytes(10); DESCRIPTION
Crypt::OpenSSL::Random provides the ability to seed and query the OpenSSL library's pseudo-random number generator EXPORT None by default. Static Methods random_bytes This function, returns a specified number of cryptographically strong pseudo-random bytes from the PRNG. If the PRNG has not been seeded with enough randomness to ensure an unpredictable byte sequence, then a false value is returned. random_pseudo_bytes This function, is similar to c<random_bytes>, but the resulting sequence of bytes are not necessarily unpredictable. They can be used for non-cryptographic purposes and for certain purposes in cryptographic protocols, but usually not for key generation etc. random_seed This function seeds the PRNG with a supplied string of bytes. It returns true if the PRNG has sufficient seeding. Note: calling this function with non-random bytes is of limited value at best! random_egd This function seeds the PRNG with data from the specified entropy gathering daemon. Returns the number of bytes read from the daemon on succes, or -1 if not enough bytes were read, or if the connection to the daemon failed. random_status This function returns true if the PRNG has sufficient seeding. BUGS
Because of the internal workings of OpenSSL's random library, the pseudo-random number generator (PRNG) accessed by Crypt::OpenSSL::Random will be different than the one accessed by any other perl module. Hence, to use a module such as Crypt::OpenSSL::Random, you will need to seed the PRNG used there from one used here. This class is still advantageous, however, as it centralizes other methods, such as random_egd, in one place. AUTHOR
Ian Robertson, iroberts@cpan.com SEE ALSO
perl(1), rand(3), RAND_add(3), RAND_egd(3), RAND_bytes(3). POD ERRORS
Hey! The above document had some coding errors, which are explained below: Around line 62: '=item' outside of any '=over' Around line 93: You forgot a '=back' before '=head1' perl v5.14.2 2007-05-20 Random(3pm)
All times are GMT -4. The time now is 12:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy