aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-105/abigail/README.md1
-rw-r--r--challenge-105/abigail/fortran/ch-1.f9027
2 files changed, 28 insertions, 0 deletions
diff --git a/challenge-105/abigail/README.md b/challenge-105/abigail/README.md
index f48953ce9f..b45353bc37 100644
--- a/challenge-105/abigail/README.md
+++ b/challenge-105/abigail/README.md
@@ -20,6 +20,7 @@ Output: 2.02
* [AWK](awk/ch-1.awk)
* [bc](bc/ch-1.bc)
* [C](c/ch-1.c)
+* [Fortran](fortran/ch-1.f90)
* [Lua](lua/ch-1.lua)
* [Node.js](node/ch-1.js)
* [Perl](perl/ch-1.pl)
diff --git a/challenge-105/abigail/fortran/ch-1.f90 b/challenge-105/abigail/fortran/ch-1.f90
new file mode 100644
index 0000000000..54af8a6cd2
--- /dev/null
+++ b/challenge-105/abigail/fortran/ch-1.f90
@@ -0,0 +1,27 @@
+!
+! See ../README.md
+!
+
+!
+! Run as: gfortran -o ch-1.o ch-1.f90; ./ch-1.o
+!
+! Input will consist of lines; each line will have two numbers, N and k, N > 0,
+! k > 0. For each line of input, we output a line with the Nth root of k.
+!
+! We're not doing any input validations; we're assuming it's correct.
+!
+
+!
+! To find the Nth root of a number k, we just raise k to the power 1/N
+!
+
+program nth_root
+ implicit none
+ integer :: N, k, ios
+
+ do
+ read (*, *, IOSTAT = ios) N, k
+ if (ios /= 0) exit
+ write (*, *) k ** (1.0 / N)
+ end do
+end