Snippets

sironekotoro Perl入学式 2018 第2回 復習問題 sum.pl

Created by sironekotoro
#!/usr/bin/env perl
use strict;
use warnings;

# Perl入学式 2018 第2回 復習問題
# https://github.com/perl-entrance-org/workshop-2018/blob/master/2nd/practice.md
# 復習問題(sum.pl)

# 1から100までの値を配列に格納し, その配列の全ての数値を足した結果を出力するsum.plを作成しよう

my @number = ( 1 .. 100 );
my $sum    = 0;
for my $num (@number) {
    $sum += $num;
}
print $sum; # 5050

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.