Modulo

I did some stuff with it in c++ but I don’t know how to use the equivalent in codea

Like how would I get numbers divisible by 2 from numbers, say (2,42) so these numbers would be (2,4,6,8,…)
I think I would do something like 42%2 in c++ but please help

Plox halp

I believe the equivalent in Lua is still 42%2 (or math.mod).

Or maybe I’m thinking of another math function. I dunno, try it yourself.

I swear I can’t code when I’m not on my ADHD medication, but I’ve tried fmod( x, y ).

Supposedly it displays the remainder of x by y, I’ll try (2,12) and it comes to 2 everytime. I don’t even know what I’m talking about anymore I think

for k=2,42,2 do
   print(k)
end

@Wallisch_pls Here’s an example using % to show “values of 2” and “values of 7”.


function setup()
    print("\
values of 2")
    for z=1,21 do
        if z%2==0 then
            print(z)
        end
    end

    print("\
values of 7")
    for z=1,50 do
        if z%7==0 then
            print(z)
        end
    end
end