If the frequency is prime
if ( prime [ it . getValue ( ) ] ) { sum += it . getValue ( ) ; product *= it . getValue ( ) ; } } System . out . print ( " Sum ▁ = ▁ " + sum ) ; System . out . println ( " Product = " + product); }