Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Untitled
SUBMITTED BY:
Guest
DATE:
March 3, 2014, 12:08 p.m.
FORMAT:
Text only
SIZE:
533 Bytes
Raw
Download
Tweet
HITS:
1188
Go to comments
Report
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int main(int argc, char *argv[]){
int k = atoi(argv[argc-2]);
int l = atoi(argv[argc-1]);
if (k<l){
k ^= l; l ^= k; k ^= l;
}
int ki = k, li = l;
int fn = INT_MAX;
while (l!=0){
printf("%i = %i * %i + %i\n",
k, (int)(k/l),
l, k%l);
int cf = (int)(k%l);
k = l;
l = cf;
if ((l!=0)&&(l<fn)){
fn = l;
}
}
printf("NWD(%i,%i) = %i\n",ki,li,fn);
return 0;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus