首项为一,等比为2
#include<iostream>
using namespace std;
int series(int n)
{
return n==1?1:2*series(n-1);
}
int main ()
{
int n,a;
cout<<"please input the n==? /n"<<endl;
cin>>n;
a=series(n);
cout<<"a("<<n<<")="<<a<<endl;
return(0);
}
#include<stdio.h>
int series(int n)
{
return n==1?1:2*series(n-1);
}
int main ()
{
int n,a;
printf("please input the n==? /n") ;
scanf("%d",&n);
a=series(n);
printf("a(%d)=%d /n",n,a);
return(0);
}
|
|