Number of k-APs in Z/NZ? Let $\mathbb{Z}/N\mathbb{Z}$ be the module class of an integer $N$. Let $k$ be an integer and we may assume $N$ is much larger than $k$ to avoid some trivial case. If necessary, we can also assume $N$ is a prime.
A $k$-term arithmetic progression ($k$-AP) $K$ in $\mathbb{Z}/N\mathbb{Z}$ is a set of $k$ distinct numbers in $\mathbb{Z}/N\mathbb{Z}$ so that you can name them $a_1,a_2,...,a_k$ with $a_i\equiv a_1+(i-1)d$ (mod $N$) for some $d\in \mathbb{Z}/N\mathbb{Z}$ and all $i=1,…,k$.
Question: how many $k$-APs in $\mathbb{Z}/N\mathbb{Z}$?
To solve this question, my idea is to first consider how many $k$-AP contains a fix number $x$: there are $k$ ways to determine the place of $x$ in a $k$-AP, and then there are $N-1$ ways to determine the "common difference" $d$. Then we can determine a $k$-AP containing $x$. So by a double-counting argument, there are $k(N-1)N/k=N(N-1)$ many $k$-APs in total. While I am not sure if $k(N-1)$ overcounts.
 A: You're nearly there. I'll work with a slightly simpler phrasing of your argument: there are $N$ ways to choose the first element $a_1$ (it may be any element of $\mathbb Z/N\mathbb Z$), and there are $N-1$ ways to choose the difference (since it cannot be $0$).
However, are all differences possible? What if $N=4$, $d=2$, and $k=3$? Then, the terms are $\{a_1,a_1+2,a_1+4\}$, but $a_1+4=a_1$ in $\mathbb Z/N\mathbb Z$. If $N$ is prime, then this issue doesn't arise for $k<N$, as for any $d\in\mathbb Z/N\mathbb Z$ nonzero, the terms $\{a_1,a_1+d,\dots,a_1+(k-1)d\}$ are distinct. However, for $N$ composite, you need to remove every $d$ for which $jd\equiv 0\pmod N$ for some $1<j<k$, i.e. those $1\leq d\leq N-1$ for which
$$\frac Nk<\gcd(d,N).$$
I don't think there's an explicit form for the number of such $d$, but you can count them for any given $N$ and $k$ if you'd like, and then multiply by $N$ to get the number of arithmetic progressions. (Again, if $N$ is prime, then the answer is what you got: $N(N-1)$.)
