Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

All Print does is print the numbers in the output line, in this case it is not necessary at all.

There are a few ways of getting the list you are looking for. The most straightforward, and useful for learning how Mathematica does things, is

Table[Prime[i], {i, 1, 4, 1}]
(* {2, 3, 5, 7} *)

Once you figure out what that means, you can use shorthand to get it quicker

Prime@Range@4
(* {2, 3, 5, 7} *)

If you want to select only those primes less than a certain number, one direct way to do that is to get a list of primes that is certainly larger than that, and use Select to get only the ones you want,

Select[Prime@Range@20, (# < 10 &)]
(* {2, 3, 5, 7} *)

But the better way, in that it doesn't do more work than is needed, is to follow this postthis post

Prime@Range@PrimePi@10
(* {2, 3, 5, 7} *)

All Print does is print the numbers in the output line, in this case it is not necessary at all.

There are a few ways of getting the list you are looking for. The most straightforward, and useful for learning how Mathematica does things, is

Table[Prime[i], {i, 1, 4, 1}]
(* {2, 3, 5, 7} *)

Once you figure out what that means, you can use shorthand to get it quicker

Prime@Range@4
(* {2, 3, 5, 7} *)

If you want to select only those primes less than a certain number, one direct way to do that is to get a list of primes that is certainly larger than that, and use Select to get only the ones you want,

Select[Prime@Range@20, (# < 10 &)]
(* {2, 3, 5, 7} *)

But the better way, in that it doesn't do more work than is needed, is to follow this post

Prime@Range@PrimePi@10
(* {2, 3, 5, 7} *)

All Print does is print the numbers in the output line, in this case it is not necessary at all.

There are a few ways of getting the list you are looking for. The most straightforward, and useful for learning how Mathematica does things, is

Table[Prime[i], {i, 1, 4, 1}]
(* {2, 3, 5, 7} *)

Once you figure out what that means, you can use shorthand to get it quicker

Prime@Range@4
(* {2, 3, 5, 7} *)

If you want to select only those primes less than a certain number, one direct way to do that is to get a list of primes that is certainly larger than that, and use Select to get only the ones you want,

Select[Prime@Range@20, (# < 10 &)]
(* {2, 3, 5, 7} *)

But the better way, in that it doesn't do more work than is needed, is to follow this post

Prime@Range@PrimePi@10
(* {2, 3, 5, 7} *)
added 475 characters in body
Source Link
Jason B.
  • 70.1k
  • 3
  • 144
  • 297

All Print does is print the numbers in the output line, in this case it is not necessary at all.

There are a few ways of getting the list you are looking for. The most straightforward, and useful for learning how Mathematica does things, is

Table[Prime[i], {i, 1, 4, 1}]
(* {2, 3, 5, 7} *)

Once you figure out what that means, you can use shorthand to get it quicker

Prime@Range@4
(* {2, 3, 5, 7} *)

If you want to select only those primes less than a certain number, one direct way to do that is to get a list of primes that is certainly larger than that, and use Select to get only the ones you want,

Select[Prime@Range@20, (# < 10 &)]
(* {2, 3, 5, 7} *)

But the better way, in that it doesn't do more work than is needed, is to follow this post

Prime@Range@PrimePi@10
(* {2, 3, 5, 7} *)

All Print does is print the numbers in the output line, in this case it is not necessary at all.

There are a few ways of getting the list you are looking for. The most straightforward, and useful for learning how Mathematica does things, is

Table[Prime[i], {i, 1, 4, 1}]
(* {2, 3, 5, 7} *)

Once you figure out what that means, you can use shorthand to get it quicker

Prime@Range@4
(* {2, 3, 5, 7} *)

All Print does is print the numbers in the output line, in this case it is not necessary at all.

There are a few ways of getting the list you are looking for. The most straightforward, and useful for learning how Mathematica does things, is

Table[Prime[i], {i, 1, 4, 1}]
(* {2, 3, 5, 7} *)

Once you figure out what that means, you can use shorthand to get it quicker

Prime@Range@4
(* {2, 3, 5, 7} *)

If you want to select only those primes less than a certain number, one direct way to do that is to get a list of primes that is certainly larger than that, and use Select to get only the ones you want,

Select[Prime@Range@20, (# < 10 &)]
(* {2, 3, 5, 7} *)

But the better way, in that it doesn't do more work than is needed, is to follow this post

Prime@Range@PrimePi@10
(* {2, 3, 5, 7} *)
Source Link
Jason B.
  • 70.1k
  • 3
  • 144
  • 297

All Print does is print the numbers in the output line, in this case it is not necessary at all.

There are a few ways of getting the list you are looking for. The most straightforward, and useful for learning how Mathematica does things, is

Table[Prime[i], {i, 1, 4, 1}]
(* {2, 3, 5, 7} *)

Once you figure out what that means, you can use shorthand to get it quicker

Prime@Range@4
(* {2, 3, 5, 7} *)