Matt Owen

source code for "files/pe/pe_006.pl"

return to portfolio
  1.  #!/usr/bin/perl
  2.  
  3.  use strict;
  4.  use warnings;
  5.  
  6.  my ($square_of_sums, $sum_of_squares, $k);
  7.  
  8.  $square_of_sums = $sum_of_squares = 0;
  9.  
  10.  for $k (1..100) {
  11.   $sum_of_squares += $k**2;
  12.  }
  13.  
  14.  $square_of_sums = (101*100/2)**2;
  15.  
  16.  print $square_of_sums - $sum_of_squares;