I've writtena code for the gcd of two integers a and d and these functions apply to an arithmetic progression
a_n = a + n*d n a natural number including 0 and (a,d) = 1
If (a,d)>1 I need to output the empty vector
If (a,d) = 1 I need to output the progression in vector form.
The vectors are Ndimensional and n is a loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

#include <iostream>
#include <vector>
using namespace std;
int gcd (int, int);
int a_N(int, int, int);
int main()
{
int a, d;
cout<<"Enter a value for a: "; cin>>a;
cout<<"Enter a value for d: "; cin>>d;
cout<<"The gcd of a = "<<a<< " and d = "<<d<<" is "<< gcd(a,d)<<endl;
int N;
cout<<"Calculate N terms of the progression";
cout<<"\nEnter a value for N:" ; cin>>N;
vector <int> v(N);
if(gcd(a,d)>1)
{
}
if(gcd(a,d)==1)
{
for(int n=1; n<=N; n++)
cout<<"a_N = "<< a_N(a,d,n) <<endl;
}
return 0;
}
int gcd (int a, int d)
{
int min = 1;
if(a<=d)
min = a;
else
min = d;
int k = 1;
for ( int t=2; t<=min ; t++ )
if ( ( a%t==0) && ( d%t==0) )
k = t;
return k;
}
int a_N (int a, int d, int n)
{
int an = a+d*n;
if( gcd(a,d)==1)
return an;
if( gcd(a,d)>1)
return 0;
}
 
Obviously my output for (a,d) = 1 isn't a vector but I was just desperate to output something.
Bacically I'd like help with what the push.back and pop.back commands actually do and what exactly am I looking for when I print a vector out? And how do you cout a vector?
cout<<v<<endl; is an arror as is cout<<v(N)<<endl; and a lot of other things I've tried.
I've also tried things like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

for(int n=1; n<=N; n++)
vector <int> v(N);= a_N(a,d,n);
if(gcd(a,d)>1)
{
}
if(gcd(a,d)==1)
{
cout<<"a_N = "<< a_N(a,d,n) <<endl;
}
 
but they just return errors and I'm typing things without much direction because I just don't understand the vectors at all adn my lectur notes are really bad.
I know I've asked a lot but if anyone can help me in the smallest bit I'd realy appreciate it. :)