As Xavier already said, with plain Ethereum you can not shield the data used in smart contracts. However, you could use zero knowledge proofs for this. Basically, with ZK-SNARKs, you can offload the smart contract code and private data from the chain, but let the chain validate that it's running according to a predefined algorithm.
If you store your numbers onchain as salted hashes for instance, you could have a ZK-SNARKs Programm (here written in ZoKrates DSL) of the form:
def (private field salt, private field y, private n, private n_1, field yHashA, yHashB, field nHashA, field nHashB, field n_1HashA, field n_1HashB) -> (field)
y0, y1 = sha256packed(0, 0, salt, y)
y0 == yHashA
y1 == yHashB
// ... same here for n and nHashA/B
// ... same here for n_1 and n_1HashA/B
// at this points you proved that you private fields match their corresponding public values (salted hashes)
// now you can check the constraint on y
field ok = if n < y && y < n_1 then 1 else 0 fi
Now onchain, you can store salted hashes of your numbers and let the veifier for the program above verify that provided proof for the plain value satisfies the constraint
storage[n] < y < storage[n-1]
See ZoKrates for tutorials and examples - https://zokrates.github.io
The interesting thing is that you can write additional zk-snarks for doing some other processing on the same values.
Also interesting to read: https://blog.decentriq.ch/zk-snarks-primer-part-one/