Refactor on #factors and #check_cache - use turnary & symbol modulo