Advertisement
Guest User

test

a guest
Mar 5th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int modulo(int x, int y){
  6.  
  7. while(x >= y){
  8.  
  9. x -= y;
  10. }
  11.  
  12. return x;
  13.  
  14. }
  15.  
  16. int Prem(int aff){
  17. int i;
  18. int view;
  19.  
  20. for(i=2;i<aff;i++){
  21.  
  22. view = modulo(aff, i);
  23.  
  24. if(view == 0){
  25.  
  26. return 0;
  27. }
  28.  
  29.  
  30. }
  31.  
  32. return 1;
  33.  
  34.  
  35.  
  36.  
  37. }
  38.  
  39. int PGCD(int a, int b){
  40.  
  41. if(b == 0){
  42. return a;
  43. }else{
  44.  
  45. return PGCD(b,modulo(a,b));
  46. }
  47.  
  48.  
  49. }
  50.  
  51. int rechPrem(int n){
  52.  
  53. int i;
  54. int res;
  55.  
  56. for (i=3; i<n; i++) {
  57.  
  58. res = PGCD(n,i);
  59.  
  60. if(res == 1){
  61.  
  62. return i;
  63. }
  64.  
  65.  
  66. }
  67.  
  68. return 0;
  69.  
  70. }
  71.  
  72.  
  73.  
  74. int main(int argc, const char * argv[]) {
  75. int x = 6;
  76. int res;
  77.  
  78. res = rechPrem(x);
  79. printf("%d",res);
  80.  
  81.  
  82.  
  83. return 0;
  84. }
  85.  
  86.  
  87. int rechercheInverse(int c,int n){
  88.  
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement