Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Function for a specific numeric sequence without any parameters

I got an university task which i am totally stuck on. Normally I wouldn’t post about it here, but none of my colleagues has any idea how to solve it.
The Task:

Design an algorithm "NEXT", which delivers the subsequent value of the numeric sequence {0,3,5,6,9,10,12,15,18,20,21,…} as function value whenever it is called. The algorithm must not use parameters or global variables or vectors.

I have to implement it in C++ (which shouldn’t be too much of an issue for me). I just have no idea how. I can’t find any form of rule for the number sequence. And i am kinda stuck on the part where i have to return the next value of the sequence without giving any parameters to the function.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It would be awesome if someone could help me out here 🙂

(FYI, i had to translate the task and i hope I didn’t make any critical Errors… Here it is again in the original languge german:
Entwerfen Sie einen Algorithmus N E X T, der bei jedem Aufruf den
jeweils nachsten Wert der Folge {0,3,5,6,9,10,12,15,18,20,21,…} als Funktionswert liefert.
Der Algorithmus darf weder Parameter haben noch globale Variablen oder Vektoren verwenden.)

>Solution :

The sequence consists in all multiples of 3 or 5, in increasing order.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading