-
-
Save ohno/2dc6023082659a315577fdb86aa4627c to your computer and use it in GitHub Desktop.
mod in Julia & Fortran
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program main | |
implicit none | |
integer :: i | |
do i = -6,6 | |
print *, i, mod(i,3) | |
end do | |
end program main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in -6:6 | |
println(i, "\t", mod(i,3)) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in -6:6 | |
println(i, "\t", i<0 ? -mod(-i,3) : mod(i,3)) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program main | |
implicit none | |
integer :: i | |
do i = -6,6 | |
print *, i, mod(abs(i+3),3) | |
end do | |
end program main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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