Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Arithmetic/Geometric - For/Loop
Author Message
hobag

Posted: Wed Feb 21, 2018 7:21 pm   Post subject: Arithmetic/Geometric - For/Loop

Can someone help me? i have a crucial assignment for class and my teacher can't help me/explain. Its about adding, and listing arithmetic and geometric sequences.
If you guys could help that would be awesome.
3 Questions;

b.) Using a for structure, determine the next 5 terms;
4, -6, 9, -13.5, _, _, _, _, _

c.) Using a for structure, find the sum;
-17 -14 -11 _, _, _, _, _

d.) Using a loop structure, find the sum;
3 - 6 +12 - 24 + ...49152 - 98304

im really new to this.
[/b]

Srlancelot39

Posted: Thu Feb 22, 2018 9:57 am   Post subject: Re: Arithmetic/Geometric - For/Loop

What have you tried so far? I doubt your teacher would give you this assignment without first teaching how to use for and loop, and if they haven't for whatever reason, there's lots of existing resources and tutorials.

In all three questions, the numbers increment by a calculable amount (plus a small twist for b and d) making a for statement an ideal solution. Do something inside the loop that keeps track of the calculated numbers/sums.
hobag

Posted: Thu Feb 22, 2018 5:51 pm   Post subject: RE:Arithmetic/Geometric - For/Loop

i figured out question c). (i think)
but how do i do add AND subtract for geometric sequences?
Srlancelot39

Posted: Thu Feb 22, 2018 10:16 pm   Post subject: RE:Arithmetic/Geometric - For/Loop

Subtraction is really just addition of negative numbers...

There's an operation that can be performed every time to make every other number negative.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 4 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: