Help with handwritten advanced number system

Hi, decide to reply, I had 2-3 posts before but ive deleted other 2, and this one is because i needed and still need help, exact help with understanding what can i add or change in my advanced system

no

sorry, i dont know

i made it for help

1 Like

this isn’t even a “help” topic anymore, you’ve continued to expand your… “optimised” code despite the amount of solutions ranging from simple, complex, light, heavy. pls move this topic to #resources:community-resources

just saying…

image
image

there is a-lot of red flags which turn this entire topic over to something called “ragebait”, content that’s made to make people annoyed or irritated on purpose for clout.

if math.round(n/2) == n/2 then
--is even
else
--is odd
end

is it simple enough?

1 Like

ummm i don’t understand the hate!!! :smiley: clearly better programmer and you’re just mad smh…

I’m student, now outside in different country thats why probably

no idea how to move topic

please explain, i have no clude whats “math.round(n/2)”

thanks!!!

1 Like

If you don’t understand them we can help you understand those methods.

Watch this lol:
How you cannot escape or exit NK

that basically rounds the number in the bracket. round means making the number have no decimal .

thats what i asked for, someone who can explain me how it works step by step, not already made scripts, im n ew to thiks and i really jsut wanned an explain on how to do it and how it works

im studying outside country

how?

It amazes me how many people don’t understand jokes lmao

1 Like

That’s because this post shouldn’t be here if it really was satire.

that will return odd if the number is a decimal

Ok, then let me explain the methods that are been proposed in the first posts, let’s take the example of @2112Jay which was one of the fastest ones.

function isOdd(number)
	return number %2~=0
end

function isEven(number)
	return number %2==0
end

What this 2 function do is just to see if the number you inputted into the function parameter is divisible by “2”.

If it is it’s going to return 0 it means there is no rest and the number is divisible by 2.
If it isn’t going to return 0 it means there is rest and the number is not divisible by 2.

(the returning is true or false depending if the number is does not have rest or does have rest).

If you want to check if the number inputted is really a number you can just do:

function isOdd(number)
    assert(type(number) == "number")
	return number %2~=0
end

function isEven(number)
    assert(type(number) == "number")
	return number %2==0
end
1 Like

amazing things? well surely of with optimalized

but whats “assert”, “type”?

So, “%2” means devisible by 2 okay, == is equeals and ~= not equeals.
I kind of get it but what is assert and type?

Ok, type is just to check the variable type.

Example:

print(type(1)) --it will print "number" as "1" is a number
print(type("hello world")) --it will print "string" as "hello world" is a string

And so on, in the Roblox Docs this is all specified.

About assert it’s just a function that checks if the value inputted is nil or false if it is nil or false it’s going to error else it’s not going to do anything.

Example:

assert(1 == 2, "Math isn't broken!") --this is going to error as 1 == 2 is false
assert(type(1) == type(2), "types are broken :skull:") --this is not going to error as both types are a "number"

Hope you understood now!

you know i’m really starting to wonder if this is actual ragebait or not

2 Likes

I thought it was simple!! :thinking:

:index_pointing_at_the_viewer::smirk:

1 Like

The 100 million version works well in my game. Can’t wait for the 1 billion update.

1 Like

LOL I see what you’re trying to do but that’s extremely unoptimized and just calling the function once will probably crash the whole server. Instead, you could easily detect even numbers by using math.round(), then divided whatever you have by 2, and then check if the remainder is < 1 (less than = odd). This is the easiest solution and it wont turn your device into a oven :sob:

I appreciate your dedication in learning how to script and you’re doing well so far because functionally this does work, its just very very very inefficient especially when you can do the same thing in like 3 lines

edit: woops, nevermind lol that wont work either… I don’t know what i was thinking but you could do something like this that uses the same principle

function is_even(number)
    return math.floor(number / 2) * 2 == number
end

if is_even(number) then
    print(number .. " is even")
else
    print(number .. " is odd")
end
1 Like