Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int main(int argc, char **argv[])
- {
- int i, uInp;
- if(argc==2)
- {
- uInp = atoi(argv[1]);
- if(uInp<0)
- {
- printf("\n Negative integer is not allow.\n");
- return 1;
- }
- int sn[uInp];
- for(i=0; i<uInp; i++)
- {
- if(i == 0 || i == 1)
- sn[i]=1;
- else if(i == 2)
- sn[i]=2;
- else if(i == 3)
- sn[i]=3;
- else if((i%3) == 0)
- sn[i]=sn[i-1];
- else
- sn[i]=(sn[i-2]*2)-1;
- printf("%d ", sn[i]);
- }
- }else{
- printf("\n This program requires least one argument.\n");
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement