2020-06-20から1日間の記事一覧

Project Euler Problem7

Haskellでの方法 エラトステネスのふるいを使いました sieve :: [Int] -> [Int] sieve (x:xs) = x : (sieve $ filter ((/=0) . (`mod` x)) xs) sieve [2..] !! 10000

Project Euler Problem1

C言語で関数型プログラミングの考え方でやりました #include <stdio.h> #include <stdlib.h> struct list { int value; struct list *next; }; typedef int func_t(int); struct list *cons(int val, struct list *lst) { struct list *p; if ((p = malloc(sizeof(struct list))</stdlib.h></stdio.h>…