FFT
FFT

Reputation: 969

Missing value when using while loop

I apologize in advance for the simple question, but I have not been able to find a solution for a while. I am trying to find the least common multiple of f0 and f1. Here is my code:

f0 = 200
f1 = 300

a = f0
b = f1
r = 0

while (a!=b) {
r = a %% b
a = b
b = r
}

From this, I get:

Error in while (a != b) { : missing value where TRUE/FALSE needed

Upvotes: 0

Views: 79

Answers (1)

Ido Tamir
Ido Tamir

Reputation: 3127

Because after the second iteration r = NaN

100 = 300 %% 200
0 = 200 %% 100
NaN = 100 %% 0

Upvotes: 1

Related Questions