473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

geometric sequence

How i do write a funtion ((IsGeometric)) with variable number of arguments that takes an integer first argument followed by any number of arguments of type ((double)) and returns ((true)) uf the argument of type ((double)) forms a geometric sequence and ((false)) if they don't

Need question in 4 days

Thanks. I woudl really appreciate a response in the next 4 days
Apr 12 '10 #1
5 4009
whodgson
542 512MB
hmm....well, assuming you are aware of the properties of a geometric sequence
your isGeometric(int,double,double........double) function has only to determine whether if each term (except the first) increases or reduces by the square of its ratio. For example: a , ar, ar^2, ar^3, ar^4 ..........ar^(n-1) is a geometric sequence where ratio 'r' is being raised by increasing powers. If this is true your function should return 'true' or 1 otherwise 'false' or 0. You could do this by examining the successive powers of r or summing the first ? terms and comparing that value with what it should be using the sum formula.which is a(1-r^n)/1-r (assert r!==1). You would of course need a main () driver function to test the function as well as the appropriate #include <header> files.If you post some code there are plenty of people here to help you get it right.
Apr 12 '10 #2
newb16
687 512MB
Start with any tutorial function about va_arg. And when examining doubles for equality thing about some precision because they might not be equal because of rounding.
Apr 12 '10 #3
ok i'm still a little confused could u give me an example source code of how it should look
Apr 12 '10 #4
jkmyoung
2,057 Expert 2GB
Take the first 2 elements,
Set ratio = element 2 / element 1.

loop through double array
if an element * ratio doesn't = the next element, return false.
end loop

return true.

Be careful of rounding, and dividing by zero.
Apr 12 '10 #5
whodgson
542 512MB
Couldn`t improve on the above method set out by jkmyoung. It`s time for you to convert this into code.
Apr 13 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rom | last post by:
I need to create a utility that presents the user with a "canvas" and allows them to add geometric shapes, including lines and circles. These must be drag-able (that is, once they're on the canvas,...
0
by: Jeff D. Hamann | last post by:
Sorry for the seemingly novice posting, but I could find a solution for this on the web so far... I've been developing a database using postgresql (and loving it) and have started running into...
1
by: Henriksen, Jonas F | last post by:
Hi, I cant seem to figure out how to use the geometric shapes in postgres: my query goes like this: select lat, lon from toperation where point'(lat,lon)' @ polygon'((50,...
0
by: Jeff D. Hamann | last post by:
Sorry for the seemingly novice posting, but I could find a solution for this on the web so far... I've been developing a database using postgresql (and loving it) and have started running into...
4
by: Kevin | last post by:
I tried writing a program to get the first few terms of a geometric progression.After the execution, I got -858993460 before the start of the series.i have used int for all variables. what...
9
by: MyInfoStation | last post by:
Hi all, I am a newbie to Python and would like to genereate some numbers according to geometric distribution. However, the Python Random package seems do not have implemented functionality. I am...
14
by: pat270881 | last post by:
hello, I have to implement a sequence class, however the header file is predefined class sequence { public: // TYPEDEFS and MEMBER CONSTANTS
6
by: Defcon2030 | last post by:
<bHey, can someone help me with this? I've been working on it for a few days now, and my head's starting to spin... </b> // FILE:ex1_imp.cxx // // // // CLASS IMPLEMENTED: sequence (see ex1.h...
1
davydany
by: davydany | last post by:
Hey guys...a n00b Here for this site. I'm making a sequence class for my C++ class. And The thing is in the array that I have, lets say i put in {13,17,38,18}, when i see the current values for the...
2
by: Tony | last post by:
Hello, As a part of a personal project, I am attempting to write a computer program that can solve the following problem: Suppose I start with a finite piece of rectangle. Within this...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.