Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- float x,a;
- printf("Enter the x: ");
- scanf("%f",&x);
- printf("Enter the a: ");
- scanf("%f",&a);
- float n = x;
- int i=1;
- int was = 0;
- float sum = 0;
- while(n<a){
- printf("%d : %f\n",i,n);
- sum+=n;
- if (a==n){
- was=1;
- }
- i++;
- n = (float) pow(x,i);
- }
- printf("Sum: %f\n",sum);
- if (was)
- printf("Yes, n = a is find");
- else
- printf("No, n = a isn't find");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement