How to calculate the percentage for the values in column

Hi, I am having the file which contains the following two columns.
518 _factorial
256 _main
73 _atol
52 ___do_global_ctors
170 ___main
52 ___do_g
How can calculate the percentage of each value in the first column ?
first need to get the sum of the first column and then each value is divide by sum and multiply by 100 to get the percentage.
How can we write script for that ?

Thanks and Regards
Raja

Try this:

awk '
        NR > max { max=NR }
        { tot+=$1; v[NR]=$1; d[NR]=$2 }
        END { for (i=1; i<=max; i++) { print v*100/tot,v,d } }

' inputfile

It prints the % as the first column.

Another approach:

awk 'NR==FNR{t+=$1;next}{printf("%.2f %s\n", $1/t*100, $2)}' file file

Regards

Yep, that's much neater.