Skip to content

Instantly share code, notes, and snippets.

@ohno

ohno/mod.f90 Secret

Last active July 17, 2022 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohno/2dc6023082659a315577fdb86aa4627c to your computer and use it in GitHub Desktop.
Save ohno/2dc6023082659a315577fdb86aa4627c to your computer and use it in GitHub Desktop.
mod in Julia & Fortran
program main
implicit none
integer :: i
do i = -6,6
print *, i, mod(i,3)
end do
end program main
for i in -6:6
println(i, "\t", mod(i,3))
end
for i in -6:6
println(i, "\t", i<0 ? -mod(-i,3) : mod(i,3))
end
program main
implicit none
integer :: i
do i = -6,6
print *, i, mod(abs(i+3),3)
end do
end program main
for i in -6:6
println(i, "\t", rem(i,3))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment