inconsistent return values
in
Programming Questions
•
1 year ago
Greetings,
My goal is to return a geometric sequence of integers: the values are initially consistent, but go erratic about 50 steps into the sequence; the function returns a negative value, -59 in the case of mod 111, then repeats zero.
How might I resolve this issue?
My goal is to return a geometric sequence of integers: the values are initially consistent, but go erratic about 50 steps into the sequence; the function returns a negative value, -59 in the case of mod 111, then repeats zero.
How might I resolve this issue?
- int modVal = 1;
- int mod = 111;
- int comRatio = 2;
- void draw() {
- int modSeq = geoSeq();
- println(modSeq);
- }
- int geoSeq() {
- int result = modVal%mod;
- modVal = (modVal*comRatio);
- delay(500);
- return result;
- }
1