Inline prime calculation