Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sum of arithmetic progression #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Sum of arithmetic progression
The program needs to compute the sum of
values of that sequence. remember that an arithmetic progression with initial value a1 and ratio r is
the sequence formed by: a1, a1 + r, a1 + 2r, ···, a1 + (n - 1) r.
  • Loading branch information
thiagomonteles committed Oct 7, 2018
commit f8477241e075a2aaf1c11de73b88aa67b4dfb38a
33 changes: 33 additions & 0 deletions Loops/sum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <stdio.h>

int main(){
int a1,r,ne, nf,v,vt,ri;
scanf("%d %d %d",&a1,&r,&ne);
v = 0;
nf = 0;
ri=r;
for (nf; nf<=ne; nf++){
if(nf<ne){
v = a1+r;
r=r+r;
printf("%d\n",v);

}
}
return 0;
}
*/
example

input
2 4 5
out
50
--------
input
7 -2 20
out
-20


/*