From f8477241e075a2aaf1c11de73b88aa67b4dfb38a Mon Sep 17 00:00:00 2001 From: Thiago Monteles <37663376+thiagomonteles@users.noreply.github.com> Date: Sun, 7 Oct 2018 17:52:40 -0300 Subject: [PATCH] Sum of arithmetic progression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- Loops/sum.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Loops/sum.c diff --git a/Loops/sum.c b/Loops/sum.c new file mode 100644 index 0000000..672fff9 --- /dev/null +++ b/Loops/sum.c @@ -0,0 +1,33 @@ +#include + + 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