Posting before checking the comments.
If I take only box B I will either make 1M$ or 2M$. Omega, with its 99,9% accuracy, will likely have selected a prime number. Expected utility is 0.999 1M + 0.001 2M $ = 1M+1K $.
If I take both, I will either get 1M+1K $ or 2M +1K $. Already I'm grabbing both boxes, because the expected utility is clearly higher. Omega would likely have selected a composite number. Expected utility is therefore 0.999 2001 K + 0.001 1001 K = 2M $.
In cases where the Lottery number doesn't match Omega's, I have a number of general strategies available, most of which might get me hit by the trolley depending on how it defines factoring. Does checking whether the ones digit is even or the number 5 count? Does summing the digits (and then the digits of the sum recursively if needed) and checking if the result is 3, 6 or 9 count? Using these two strategies would improve my odds significantly, but risks the wrath of the trolley.
You see two boxes and you can either take both boxes, or take only box B. Box A is transparent and contains $1000. Box B contains a visible number, say 1033. The Bank of Omega, which operates by very clear and transparent mechanisms, will pay you $1M if this number is prime, and $0 if it is composite. Omega is known to select prime numbers for Box B whenever Omega predicts that you will take only Box B; and conversely select composite numbers if Omega predicts that you will take both boxes. Omega has previously predicted correctly in 99.9% of cases.
Separately, the Numerical Lottery has randomly selected 1033 and is displaying this number on a screen nearby. The Lottery Bank, likewise operating by a clear known mechanism, will pay you $2 million if it has selected a composite number, and otherwise pay you $0. (This event will take place regardless of whether you take only B or both boxes, and both the Bank of Omega and the Lottery Bank will carry out their payment processes - you don't have to choose one game or the other.)
You previously played the game with Omega and the Numerical Lottery a few thousand times before you ran across this case where Omega's number and the Lottery number were the same, so this event is not suspicious.
Omega also knew the Lottery number before you saw it, and while making its prediction, and Omega likewise predicts correctly in 99.9% of the cases where the Lottery number happens to match Omega's number. (Omega's number is chosen independently of the lottery number, however.)
You have two minutes to make a decision, you don't have a calculator, and if you try to factor the number you will be run over by the trolley from the Ultimate Trolley Problem.
Do you take only box B, or both boxes?