C++ sequences

Hi guys,
I am writing this post, not to ask for an answer to a question, but to ask for questions. I have a test on C++ this Wednesday, and I need to practice on sequences.
A sequence is something like this:
5 10 20 25 35 40 50 55 65 70
or
0 1 2 2 3 4 5 5 6 7
or

1 1 2 3 5 8 13 21 34 55

Please, guys, help me ace this test; I prefer tough sequences.
Thank you

In other words, you don't actually ask about C++?
https://oeis.org/wiki/Welcome
The obvious question this would raise is, "How would you program the above sequences?"

All sequences require some sort of loop, preferably a for loop or a while loop (less preferably, recursion). Do you know how to write a for loop that would increment by 5 each time, and print 10 numbers starting at 5?

I don't know what your second sequence is, but it looks like something related to musical scales?

Your third sequence is the Fibonacci sequence, where the third number is the sum of the previous two numbers. Can you give an attempt at programming this? If so, I think you'd have a good grasp at basic sequences.

Somewhat harder sequences would be the power series approximation for e, or sequences that sum to approximate pi, but that might be out of scope for your test.
I know the answer to all the above sequences with for loops (actually the second sequence is based on the first). I just want to ask if anyone has harder or tricker questions, so I can practice.
Thanks
Coding any sequence is usually simple. Some are just a direct computation (eg fibonacci can be directly computed for the nth term) and others are just a loop. As often as not the problem is finding the pattern more than coding it.

in practice (real world problems) you can often write throw-away code to generate the first N terms (N usually being a few hundred at most) and then drop them into a constant vector lookup table. Examples of this are factiorials and related values used in probability -- you rarely need more than the first 20 or so and often less than that...


Ok, thank you
Take a look at project euler:

https://projecteuler.net
Topic archived. No new replies allowed.