hi im new to c# and was trying to code but getting error can anybody help me with this what am i doing wrong?
using System;
using System.Collections.Generic
@jalf: is correct about the case where 2 <= n/2 (i.e., 4<=n). You will never enter the for loop in that case, so you need the return after the for
.
As @Kenny suggested,
if ((n % 1) == 0)
Is suspect. n % 1 always == n, so the condition will only be true when n == 0. However, it also looks like this might be a typo, since the condition does not test anything that varies within the loop. Did you mean
if ((n % i) == 0)
?