Generation II
In Generation II, Shininess is determined by the IVs of a Pokémon. If
a Pokémon's Speed, Defense, and Special IVs are 10, and its Attack IV
is 2, 3, 6, 7, 10, 11, 14 or 15, it will be Shiny. Due to the HP IV
being determined by the other four IVs, a Shiny Pokémon's HP IV can
only be 0 or 8. This is because HP takes the final binary digit of the
Attack, Defense, Speed, and Special IVs and places it, in that order,
for its own IV. The last 3 binary digits are always 0 because those
IVs have to be 10 (1010 in binary) for Shiny Pokémon. The first digit
depends on whether or not the Attack IV is even (then it is 0) or odd
(then it is 1). This means that the HP IV can either be 0000 (0) or
1000 (8).
Generations III, IV, and V
In Generation III, most of the data structures were redone. As such, a
Pokémon's Shininess would no longer need to be linked to its stats due
to incompatibilities between the previous generations. The determinant
for Shininess is instead a calculation based on the Trainer ID number
and secret ID number of the player encountering it and the personality
value of the Pokémon. The same method is used in Generations IV and V.
The secret ID and Trainer ID byte words are first xored together, and
then the first byte word of the personality value is xored with the
second byte word of the personality value. If the xor of these two
results is less than eight, then the Pokémon is Shiny. This results in
a probability of 8 in 65536; simplified as 1/8192 (2-13, or
0.01220703125%), just as in Generation II. Symbolically: (Trainer ID) xor (Secret ID) = E (First byte word of personality value) xor (Second
byte word of personality value) = F If E xor F is less than eight,
then the Pokémon is Shiny.
Bulpapedia
However, Victini, Zekrom, and Reshiram, or any Pokemon from the Dream World cannot be shiny unless you cheat