the digits we can use are 2 , 3 ,5 and 7

since every pair of two digits in a five digit number can't be prime

so we can't have , 23 , 53 and 73 , so 3 must be at first place in any case

for the largest number we have

3 5 7 7 2

and smallest number is

3 2 2 5 7