Skip to content

Instantly share code, notes, and snippets.

@mattn
Forked from rummelonp/sum.c
Created March 26, 2012 05:12
Show Gist options
  • Save mattn/2203144 to your computer and use it in GitHub Desktop.
Save mattn/2203144 to your computer and use it in GitHub Desktop.
変数は新たに宣言しない1から100までの整数の和を表示するプログラム
#include <stdio.h>
int main(int argc, char* argv[]) {
argc = 0;
argv[0] = 100;
while (argv[0] > 0) {
argc += argv[0];
argv[0] -= 1;
}
printf("%d\n", argc);
return 0;
}
(print (apply + (range 1 101)))
<?php
echo array_sum(range(1, 100)), "\n";
use List::Util sum;
print sum(1..100), "\n";
print sum(range(100 + 1))
puts (1..100).inject(:+)
:echo eval(join(range(1,100), '+'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment