+ 1
How does it works?
I may not understand the condition ~-2**n%n <2. Help, please! https://code.sololearn.com/codcoa5mYJGS/?ref=app
5 Respostas
+ 1
Don't worry, I don't understand it very well either.
So ~-2**n inverts all's the bits in -2**n, which means that you have all ones except on the most significant nth least significant bits.
then you mod n that (positive) number and take it if you have a result of 0 or 1...
no idea why, however, I've just decomposed the execution steps
+ 1
I have known something about it.
Nobody don't know formula to find all prime nuns. But this works properly with small nums. You may find something like this in Wikipedia.
+ 1
P.S. Sorry for my bad English.
0
"~" is the Bitwise not operator it works like
~10
binary of 10 : 1010
now taking negation on all bits;
0101
every 1 becomes 0 and every 0 becomes 1
so the result is int(0101)
so this is 5 as binary of 5 is 101
0
@Atikant hum... did ~10, got -11...