in reply to Dice roll chances
apart from the long title (I used the better one used by toolic) and the poorly formatted text I suggest you to sign in order, in the future, to be able to edit your own post. For you personal colture PERL does not exists: Perl is the language name and perl is the program that executes your programs.
The, first, basic rule in programming is to translate a spoken problem or algorithm to a program.
> I must write a PERL program that randomly generates a number between 1 and 50 in groups of 5. Sum each group and display the results so that each number is on its own line.
The missing spec is: how many times you want to do this? let's say 3 time..
Let's see:
# a PERL program that.. use strict; use warnings; # the missing spec: 3 times for (1..3){ my $sum; # in groups of 5 for (1..5){ # randomly generates a number between 1 and 50 # Sum each group $sum += int (rand(50)+1); } # display the results so that each number is on its own line print "$sum\n"; }
L*
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sum group of numbers and display each number is on its own line -- plain way
by Laurent_R (Canon) on Nov 11, 2017 at 22:40 UTC | |
by 1nickt (Canon) on Nov 12, 2017 at 00:15 UTC | |
by Laurent_R (Canon) on Nov 12, 2017 at 09:30 UTC |