Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. int coprime(int a, int h)
  5. {
  6. int temp;
  7. while(1){
  8. temp = a%h;
  9. if(temp==0)
  10. return h;
  11. a = h;
  12. h = temp;
  13. }
  14. }
  15.  
  16. int main()
  17. {
  18. int c=1,i,t[50],nbt,k,j,test,taill;
  19. scanf("%d",&nbt);
  20. for(i=0;i<=nbt;i++){
  21. scanf("%d",&taill);
  22. for(j=0;j<taill;j++){
  23. scanf("%d",&t[j]);
  24. }
  25. for(k=0;k<taill;k++){
  26. test=coprime(t[k],t[k+1]);
  27. if(test==1&&(t[k]<t[k+1])){
  28. c++;
  29. }
  30. }
  31. printf("sequence of co primes : %d \n",c);
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement