I want to create a simple function that prints all prime numbers from 1 to x. I have the following code, which doesn't cause any errors from the kernel but it doesn't return anything:
allprimes[x_] = For[i=0, i<=x, i++,
If[PrimeQ[i], Print[i]]]
What have I done wrong?
allPrimes[i_] := Select[Range[i], PrimeQ]? – halirutan Feb 08 '19 at 03:15:=instead of=to define the function. Example:f[x_] := x^2– Somos Feb 08 '19 at 03:27