Skip to content

Commit

Permalink
Move stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
dnery committed Oct 22, 2019
1 parent ccd5469 commit 8336804
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions Euclidean_Algorithm.c → misc/mod_inverse_euclidean_algorithm.c
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
#include<stdio.h>
#include<conio.h>

void main()
{
int n=0,b=0,x,r1,r2,t1,t2,q,r,t,d;
clrscr();
printf("Enter the number a : ");
scanf("%d",&b);
printf("Enter the number n : ");
scanf("%d",&n);

r1=n;
r2=b;
t1=0;
t2=1;

while(r2>0)
{
q=r1/r2;
r=r1-q*r2;
r1=r2;
r2=r;
t=t1-q*t2;
t1=t2;
t2=t;
}

if(r1==1)
{
if(t1>0)
{
d=t1;
}
else
{
d=t1+n;
}

printf("\n The inverse of %d mod %d is : %d ",b,n,d);
getch();
}
else
{
printf("\n The inverse does not exist. ");
}

#include<stdio.h>
#include<conio.h>

void main()
{
int n=0,b=0,x,r1,r2,t1,t2,q,r,t,d;
clrscr();
printf("Enter the number a : ");
scanf("%d",&b);
printf("Enter the number n : ");
scanf("%d",&n);

r1=n;
r2=b;
t1=0;
t2=1;

while(r2>0)
{
q=r1/r2;
r=r1-q*r2;
r1=r2;
r2=r;
t=t1-q*t2;
t1=t2;
t2=t;
}

if(r1==1)
{
if(t1>0)
{
d=t1;
}
else
{
d=t1+n;
}

printf("\n The inverse of %d mod %d is : %d ",b,n,d);
getch();
}
else
{
printf("\n The inverse does not exist. ");
}

}

0 comments on commit 8336804

Please sign in to comment.