This is true. Fun fact VEX Robotics V5 block code is just Scratch but for Vex V5. If you don’t understand what this means, that is fine, I guess.
bump cuz ye.
I’m going to try and revive bitwise operations in my wiki.
There needs to be a way without using sums.
by 2^n, what do you mean? is “n” any positive integer?
2863311530 is 10101010101010101010101010101010 in base 2
also, what is the goal of the problem?
to find the result of the bitwise AND operation?
Yeah, he said it needs to be able to solve due any value of n.
IDK I’m in the wrong department fella! I work to help with gimkit!
Ok
lets split this into 3 cases:
Case 1: n is odd and less than 32
Notice that in 10101010101010101010101010101010, each 1 is in the evens digit. In other words, it could be written as 2^31 + 2^29 +2^27 … + 2^1 (Note that the first digit of base 2 is written as 0 x 2^0, so each digit after that increases its power by one). Since n is odd and less than 33, it’s base 2 representation is 1000…000 with n zero’s. The one at the front also coincides with one of the original number’s digits. Since the Bitwise AND operation multiplies corresponding digits, everything will cancel out (due to the zero’s) except for the corresponding 1’s, which stay as a 1. The result is 2^n
Case 2: n is even and less than 32
Remember that 10101010101010101010101010101010 can be written as 2^31 +2^29 +… + 2^1
Since n is even, the resulting leading 1 won’t coincide with any of the 1’s.
Thus, everything cancels out and the result is 0.
Case 3: n is greater or equal to 32
In this case:
n>32
2^n > 2^32
2^n > 2^31 + 2^31
2^n > 2^31 + 2^30 + 2^30
2^n > 2^31 + 2^30 + 2^ 29 + 2^29
and so on, until
2^n > 2^31 + 2^30 + 2^29 … + 2^3 + 2^2 + 2^1 + 2^0 + 2^0
We can remove the second 2^0
2^n > 2^31 + 2^30 + 2^29 … + 2^3 + 2^2 + 2^1 + 2^0
Now, notice that
2^31 + 2^30 + 2^29 … + 2^3 + 2^2 + 2^1 + 2^0 > 2^31 + 2^29 +2^27 … + 2^1
Since this expression is greater than the number, and 2^n is greater than the expression, we have
2^n > 2^31 + 2^29 +2^27 … + 2^1
What does this mean?
Well, this means that the leading digit 1 in 2^n will not coincide with any of the number’s digits. Since there are no coinciding 1’s, the result is 0.
Coding this in gimkit:
if {n>32}
do [set property: result
[value : 0
else if {n is odd}
do [set property: result
[value : {2^n}
else if {n is even}
do [set property: result
[value : 0
We don’t need to add {n<32} for the 2nd and 3rd conditionals because we already have it in the first.
DICLAIMER: This does not include negative numbers, so in the next post I’ll be covering those.
obviously, a six yr old doesn’t even know algebra
Case 4: n is negative
This brings us to the world of decimals in different bases
For time’s sake, I’ll assume readers know about decimal representations in different bases
If n is negative, the result will be something like this 0.00…0001
Assuming Bitwise AND operations work on decimals, the result will be 0, as no 1’s coincide with each other.
Case 5: n is zero
2^0 = 1
No 1’s coincide. the result is 0
Updated Block Code:
(coming soon)
Updated block code:
if {n>32}
do [set property: result
[value: 0
else if {n is negative}
do [set property: result
[value: 0
else if {n is 0}
do [set property: result
[value: 0
else if {n is even}
do [set property: result
[value: 0
else
do [set property: result
[value: {2^n}
I’ll show this to black hole and see what he says. What math are you in?
isn’t that sharing personal info
im in alg 1
in school, im in geometry
in technical terms, i honestly dont know
im taking the AIME in february this year
Really??? Wow… I’m only taking AMC 8…
I’m in alg1…
@Pika_Pokemon You shouldn’t tell me if you wanted to build a base…
kool
amc 10 is better tho
ummm uhhh. i thought my relay only sent notified @ClicClac . oh wait a sec. I dont have a relay!
We should probably take this conversation to the pad let, drop-downs don’t do anything to hide off topic posts.
what padlet?