I just finished a project where I had to cut foam board, then paint it, and had trouble finding a definitive answer to the question of whether or not to prime it first, so I thought I'd post my experience with it. The foam board - also called foam core board - had a fairly matte paper finish on both sides of it (I used Elmer's brand), so I painted right onto it without priming. I had read that the stuff doesn't warp when paint is applied to it. Wrong! It did warp while wet, but as it dried, it flattened back out. I would recommend letting it dry on a flat surface because of this.
I also was painting a piece of rigid foam insulation, which I was using as the surface to which I would be mounting the foam board. This had a plastic film on one side, and foil on the other, but the same recommendation applies to the plain foam insulation with no coatings: PRIME IT! I used Zinsser Sealer/Primer. It rolled on smoothly, and dried very quickly. The can says 30 minutes dry-time, but it was more like 15. It gave a nice "tooth" to the surface, so that the acrylic paint could grip and hold. I used a foam roller to apply both the primer and the paint. The acrylic paint was dry to the touch after 15 minutes, but I gave it 30 minutes before applying a second coat. Only two coats were needed for the black parts, but a third coat was need for the parts I was painting red, which is usually the case when you're painting anything red. It is a "weak" color, even though it wouldn't seem so. Hope this helps someone else looking at painting these two types of foam products.