# Last three numbers of multiple of four primes

If we have four two-digit prime numbers $$p_1$$, $$p_2$$, $$p_3$$ and $$p_ 4$$ such that they all end with a different number. For example 11, 13, 17 and 19. What can be the last three digits of $$p_1p_2p_3p_4$$? It is pretty obvious that the last digit has to be $$9$$ since $$1\cdot3\cdot7\cdot9 \equiv 9$$ (mod $$10$$), but I have a tough time figuring out that this number can be mod $$1000$$.

• There are only a few two-digit prime numbers. – Dietrich Burde Apr 14 at 18:51
• By my count there are $750$ possible products. Can you enumerate them? – Oscar Lanzi Apr 14 at 22:47

Here is a program in Ocaml that checks it I think:

let whatweneed=[[11;31;41;61;71];[13;23;43;53;73;83];[17;37;47;67;97];[19;29;59;79; 89]]

let rec makelists ll =
match ll with
|q::w -> [q]::makelists w
|[] -> []

let rec appendele l1 l2=
match l1 with
|q::w -> (List.map (fun x -> q::x) l2) @ (appendele w l2)
|[]->[]

let rec oneineach ss=
match ss with
|q::w ->appendele q (oneineach w)
|_->[[]]

let combinations = oneineach whatweneed

let multall= List.map (fun y -> (List.fold_left (fun acc x->acc*x) 1 y)) combinations

let multallmodthousand = List.map (fun x -> x mod 1000) multall

let rec removeDuplicates lst =
match lst with
| [] -> []
| x :: xs -> x :: (List.filter (fun u -> not (u = x)) (removeDuplicates xs));;

let finalresult = removeDuplicates multallmodthousand


Here are the results:

$$[189; 499; 429; 49; 359; 529; 439; 169; 989; 899; 699; 909; 539; 959; 39; 849; 279; 709; 549; 259; 389; 809; 519; 719; 729; 759; 779; 789; 859; 469; 299; 129; 929; 839; 569; 69; 579; 109; 639; 689; 919; 739; 149; 419; 239; 649; 559; 589; 629; 249; 769; 979; 599; 409; 309; 749; 969; 79; 819; 619; 659; 679; 159; 509; 369; 879; 939; 949; 489; 219; 229; 289; 89; 269; 99; 319; 209; 339; 19; 29; 59; 139; 479; 669; 329; 999; 829; 349; 399; 199; 459; 889; 799; 9; 379; 449; 869; 119; 609; 179]$$