March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -1,20 +1,18 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int mul_inv(int a, int b)
|
||||
{
|
||||
int b0 = b, t, q;
|
||||
int x0 = 0, x1 = 1;
|
||||
if (b == 1) return 1;
|
||||
while (a > 1) {
|
||||
q = a / b;
|
||||
t = b, b = a % b, a = t;
|
||||
t = x0, x0 = x1 - q * x0, x1 = t;
|
||||
}
|
||||
if (x1 < 0) x1 += b0;
|
||||
return x1;
|
||||
#include<stdio.h>
|
||||
int modularinverse( int a, int b){
|
||||
int c=b/a,x=0;
|
||||
do{
|
||||
if((a<b)||(a==1)) x=1;
|
||||
if((c*a)%b==1) x=c;
|
||||
else c++;
|
||||
} while(x==0);
|
||||
return x;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
printf("%d\n", mul_inv(42, 2017));
|
||||
int main()
|
||||
{
|
||||
int a,b;
|
||||
printf("Unesite brojeve a i b ");
|
||||
scanf("%d%d",&a,&b);
|
||||
printf("Modularni inverz brojeva %d i %d je %d ",a,b,modularinverse(a,b));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue