Gets complicated.
the most naive approach: trial division.
this is a way to "return" an array from a C function.
(i.e., pass the reference (aka pointer) and modify the value.)
https://github.com/yuuki15/project-euler/blob/main/src/0003.c
Gets complicated.
the most naive approach: trial division.
this is a way to "return" an array from a C function.
(i.e., pass the reference (aka pointer) and modify the value.)
https://github.com/yuuki15/project-euler/blob/main/src/0003.c
Another "filter" pattern.
this kind of assignment in a condition may be common in C.
Fibonacci seems to have defined fibonacci numbers in this way.
https://github.com/yuuki15/project-euler/blob/main/src/0002.c
this may not be controversial.
A "filter" pattern.
in ruby:
% ruby -e 'puts (1 .. 999).filter { |i| i % 3 == 0 || i % 5 == 0 }.sum'
i.e., generates all the numbers and extracts those that meet the condition.
https://github.com/yuuki15/project-euler/blob/main/src/0001.c