A closed trail is a connected graph whose every vertex is incident to an even number of edges. We give a deterministic algorithm that in time finds the number of closed trails in a given graph G with n vertices and m edges. Moreover, within the same time bound we can determine every possible vertex set of a closed trail in G, together with the associated number of closed trails. Our algorithm can be used to deterministically find the longest cycle in an n‐vertex claw‐free graph in time via a framework presented by Broersma et al. (in press, http://dx.doi.org/10.1007/s00453-011-9576-4) , thus improving both upon the time randomized algorithm for general graphs (Björklund, 2010, http://dx.doi.org/10.1109/FOCS.2010.24), as well as the time deterministic algorithm for claw‐free graphs by Broersma et al.