Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Tính S(x,n) = x + x^2 + x^3 + ... + x^n
- // khai bao thu vien
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- // khai bao bien
- int n,x;
- // nhap du lieu
- scanf("%d%d",&n,&x);
- long T=1;
- long M=0;
- if(x==0&&n==0)
- printf("Khong xac dinh");
- else
- {
- if(x==0)
- {
- printf("0"); // xuat ra gia tri 0
- }
- else
- {
- for(int i=1;i<=n;i++)
- {
- T=T*x;
- M=M+T;
- }
- }
- printf("%ld",M);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement