Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Finding sum of numbers and storing it an Array

by BillKSmith (Monsignor)
on Sep 21, 2020 at 14:02 UTC ( [id://11121999]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
    my $totalSum = sum @nums;
    my @array = apply {$_ /= $totalSum} @nums;
    printf "Fractional Parts:\n" . "%8.6f\n" x scalar @array, @array;
    
  2. or download this
    Fractional Parts:
    0.066667
    ...
    0.200000
    0.266667
    0.333333
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121999]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found