summaryrefslogtreecommitdiff
path: root/rsa.f90
blob: d982335957df9ade8aa16fd1119b38a411c1da73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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