Question: 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.

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.)

Answer: 
The sequence consists in all multiples of 3 or 5, in increasing order.
If your professor prefers compact but unreadable code over the readable one they may like this:

```
int NEXT()
{
    static int c3 = 0, c5 = 0;
    int v3 = c3 * 3, v5 = c5 * 5;
    return v3 == v5 ? c3++, c5++, v3 : v3 < v5 ? c3++, v3 : c5++, v5;
}

```