# Simpler way to determine type of sequence Arithmetic or Geometric progression

 MAYURESH DEOLEKAR · August 6, 2014 How to determine given sequence is AP/GP#include#includeint main(){       int i,m,n,k;     int sequence[] = {1,2,5,7,9,13,98};        //CHECK FOR GP      for(i=0;i<5;i++)     {         k = sequence[i+1] % sequence;     }      printf("common factor is %d\n",k);          if(k == 0)     {          printf("The sequence is Geometric Progression\n");     }     else     {          printf("The sequence is NOT Geometric Progression\n \n \n");     }             //check for AP     m = sequence[i+1] - sequence;     n = sequence[i+2] - sequence[i+1];          printf("The common difference between 1st & 2nd and 2nd &3rd consecutive terms is %d and %d\n",m,n);          if(m==n)     {     printf("The sequence is Arithmatic Progression\n");     }     else     {     printf("The sequence is NOT Arithmatic Progression\n");     }         getch();}

## Replies

Nothing to see here.

## C

130,016 followers