aboutsummaryrefslogtreecommitdiff
path: root/challenge-105
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-03-23 00:28:12 +0100
committerAbigail <abigail@abigail.be>2021-03-23 00:28:12 +0100
commita872fa4b50f26a39937194f989437a27a7c2008a (patch)
treea2db98d18a3a4ace0eeb5161769d1f11ea381d80 /challenge-105
parent73778bb4438f496b569a60b06076b1a68ced45b4 (diff)
downloadperlweeklychallenge-club-a872fa4b50f26a39937194f989437a27a7c2008a.tar.gz
perlweeklychallenge-club-a872fa4b50f26a39937194f989437a27a7c2008a.tar.bz2
perlweeklychallenge-club-a872fa4b50f26a39937194f989437a27a7c2008a.zip
Fortran solution for week 105, part 1
Diffstat (limited to 'challenge-105')
-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