summaryrefslogtreecommitdiff
path: root/rsa.f90
diff options
context:
space:
mode:
Diffstat (limited to 'rsa.f90')
-rw-r--r--rsa.f9026
1 files changed, 26 insertions, 0 deletions
diff --git a/rsa.f90 b/rsa.f90
new file mode 100644
index 0000000..d982335
--- /dev/null
+++ b/rsa.f90
@@ -0,0 +1,26 @@
+program rsa
+ implicit none
+ integer :: n, m
+
+ print *, "Enter numbers to compute gcd:"
+ read(*,*) n, m
+
+ print *, "gcd: ", gcd(n,m)
+
+ contains
+
+ recursive function gcd(n,m) result(x)
+ implicit none
+ integer, intent(in) :: n,m
+ integer :: x
+
+ if (n == 0) then
+ x = m
+ else if (m == 0) then
+ x = n
+ else
+ x = gcd(m, mod(n,m))
+ end if
+ end function gcd
+
+end program rsa