# [Mathematica] Multiples of 5 from 0 to 100

1. Jun 19, 2014

I have downloaded Mathematica to see if it is really that good. Many people use it.
I want to calculate the multiples of 5 from 0 to 100.
This seems pretty simple but I can't figure out a way to do it.
I can't use the Modulo % in mathematica.
I know that I should use Table. Is there any other function?
I have searched google too, but could not find a solution. If project euler was online, it would have been so helpful!

Please bear with me, I have never touched Mathematica until now.

I tried this code , but it does not work;
Code (Text):
For[i = 0, i <= 100, i++,
]

Last edited: Jun 19, 2014
2. Jun 19, 2014

### .Scott

Mathematica is great - but it's been almost a decade since I last used it.
I think what you want is something like this:

Array[5*(#-1)&,21]

or

Array[5*#&,21,0]

Last edited: Jun 19, 2014
3. Jun 19, 2014

### .Scott

In your version, try "Mod[i,5] == 0".

4. Jun 19, 2014

This works, but I don't understand that code. Can you explain?
What is the need of 21 here? What is #?(Slot 1)? What is &?

Ah, my method also works now.I thought mathematica does not use ==. How will I arrange them in a table now, instead of printing on a new line?
Edit:
This is my code now
Code (Text):
n = 10;
m = 5;
For[i = 1, i <= n, i++, If[Mod[i, m] == 0, Print[i], null]]

Last edited: Jun 19, 2014
5. Jun 19, 2014

### .Scott

The first argument to array is the function that will generate the values.
The second argument is the size of the array. The set 0,5,10,...,100 has 21 elements.
If there is a third argument and it is a simple number, it is the starting index to a 1-dimensional array. Otherwise the index starts at 1.

For that first argument, the & at the end of the expression identifies it as a pure function. The # is a reference to the only argument o the function - which for the array syntax is the array index. If the pure function had more than one argument, references to those arguments would be #1, #2, ...

6. Jun 19, 2014

Thank you so much. I have managed to perfect the code:
Code (Text):
m = 3;
n = 25;
Array[m*#1 &, Floor[(n/m)]]

7. Jun 19, 2014

### .Scott

By George, I think you've got it!!

8. Jun 19, 2014

Now is there any way to make an application with this?
An .exe file?

9. Jun 19, 2014

### .Scott

I'm pretty sure there isn't. You would pretty much need the entire Mathematica engine.

10. Jun 19, 2014