  Let C(G) denote the set of lengths of cycles in a graph G. In the first part
of this paper, we study the minimum possible value of |C(G)| over all graphs G
of average degree d and girth g. Erdos conjectured that |C(G)|
=\Omega(d^{\lfloor (g-1)/2\rfloor}) for all such graphs, and we prove this
conjecture. In particular, the longest cycle in a graph of average degree d and
girth g has length \Omega(d^{\lfloor (g-1)/2\rfloor}). The study of this
problem was initiated by Ore in 1967 and our result improves all previously
known lower bounds on the length of the longest cycle. Moreover, our bound
cannot be improved in general, since known constructions of d-regular Moore
Graphs of girth g have roughly that many vertices. We also show that
\Omega(d^{\lfloor (g-1)/2\rfloor}) is a lower bound for the number of odd cycle
lengths in a graph of chromatic number d and girth g. Further results are
obtained for the number of cycle lengths in H-free graphs of average degree d.
  In the second part of the paper, motivated by the conjecture of Erdos and
Gyarfas that every graph of minimum degree at least three contains a cycle of
length a power of two, we prove a general theorem which gives an upper bound on
the average degree of an n-vertex graph with no cycle of even length in a
prescribed infinite sequence of integers. For many sequences, including the
powers of two, our theorem gives the upper bound e^{O(\log^* n)} on the average
degree of graph of order n with no cycle of length in the sequence, where
\log^* n is the number of times the binary logarithm must be applied to n to
get a number which is at most
