Skip to content

Solutions to Project Euler problems written by modern Fortran

License

Notifications You must be signed in to change notification settings

han190/PE-Fortran

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Euler solutions written in Fortran

Project Euler is a math problem set. I occasionally solve PE problems for fun. Welcome!

Getting Started

Dependencies

Dependencies Options
Fortran 2008 compliant Compiler gfortran/ifx
Build Tool Fortran Package Manager (FPM)

Run with FPM

Solve a single problem

fpm run PE-Fortran [-- p<problem number> [--trail <number of trails/problem>]]
# Example1, solve all problems: fpm run PE-Fortran
# Example2, solve all problems 10 times: fpm run PE-Fortran -- -t 10
# Example3, solve problem 10: fpm run PE-Fortran -- p10
# Example4, solve problem 10 for 100 times: fpm run PE-Fortran -- p10 -t 100
# Example5, solve all problems faster: fpm run PE-Fortran --profile release

To avoid Memory Sanitizer from the Intel Fortran compiler(ifx (IFX) 2023.2.0)

fpm run PE-Fortran --compiler ifx --flag "-check all,nouninit"

For more information: fpm run PE-Fortran -- -h

Contribution

If you would like to contribute:

Step 1

Add your file problem_xxxx.f90 to src/problems, where xxxx is the problem number with leading zeros. If a data file is required, add your data file data_xxxx.txt to data/. The syntax of a solution submodule should follow

submodule(module_problem) submodule_eulerxxxx
implicit none
contains

module subroutine eulerxxxx(problem)
   class(problem_type), intent(inout) :: problem !> Problem type
   integer :: sln !> store your answer
   !> If data file is required:
   !> open (newunit=unit, file=problem%file)
   !> ... your implementation ...
   write (problem%answer, "(i20)") sln
end subroutine eulerxxxx
end submodule submodule_eulerxxxx

Step 2

Update *.inc files by using

fpm run Preprocess

About

Solutions to Project Euler problems written by modern Fortran

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published