[Mathematica] Multiples of 5 from 0 to 100

  • Thread starter adjacent
  • Start date
  • Tags
    Mathematica
In summary, Mathematica can be helpful for calculations, but may require some understanding of calculus.
  • #1
adjacent
Gold Member
1,552
63
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:
For[i = 0, i <= 100, i++,
 If[Mod[i, 5] = 0, Print[i], Print["Not found"]
  ]
 
Last edited:
Technology news on Phys.org
  • #2
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:
  • Like
Likes 1 person
  • #3
In your version, try "Mod[i,5] == 0".
 
  • Like
Likes 1 person
  • #4
.Scott said:
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]
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:
n = 10;
m = 5;
For[i = 1, i <= n, i++, If[Mod[i, m] == 0, Print[i], null]]
 
Last edited:
  • #5
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, ...
 
  • Like
Likes 1 person
  • #6
.Scott said:
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, ...

Thank you so much. I have managed to perfect the code:
Code:
m = 3;
n = 25;
Array[m*#1 &, Floor[(n/m)]]
 
  • #7
By George, I think you've got it!
 
  • #8
.Scott said:
By George, I think you've got it!

Now is there any way to make an application with this?
An .exe file?
 
  • #9
adjacent said:
Now is there any way to make an application with this?
An .exe file?
I'm pretty sure there isn't. You would pretty much need the entire Mathematica engine.
 
  • #10
.Scott said:
I'm pretty sure there isn't. You would pretty much need the entire Mathematica engine.

I think there is something named "CDF Player"- Downloading now.
I am now realising how great Mathematica is. Far greater than I expected!
 
  • #11
adjacent said:
I think there is something named "CDF Player"- Downloading now.
I am now realising how great Mathematica is. Far greater than I expected!
If you have some sort of calculus problem, the combination of human skill and pattern recognition and Mathematica's unerring, encyclopedic, and deep analysis just makes the game a whole lot easier.
 

What is Mathematica?

Mathematica is a powerful software program used for mathematical and scientific computing. It allows users to perform various calculations, visualize data, and create interactive simulations.

How can I generate a list of multiples of 5 from 0 to 100 in Mathematica?

To generate a list of multiples of 5 from 0 to 100 in Mathematica, you can use the Range function with a step size of 5. For example, Range[0, 100, 5] will give you a list of numbers from 0 to 100 with a step size of 5.

Can I customize the output of the list of multiples of 5 in Mathematica?

Yes, you can customize the output of the list of multiples of 5 in Mathematica by using various functions such as Table, Map, or Select. These functions allow you to perform operations on the list and manipulate the output as desired.

Is it possible to plot the multiples of 5 from 0 to 100 in a graph using Mathematica?

Yes, it is possible to plot the multiples of 5 from 0 to 100 in a graph using the Plot function in Mathematica. You can specify the range, step size, and even add labels and titles to the graph for better visualization.

Can I use Mathematica for other mathematical calculations and functions?

Yes, Mathematica has a wide range of built-in functions and capabilities for various mathematical and scientific calculations. It also has the ability to perform symbolic and numerical computations, making it a versatile tool for scientific research and analysis.

Similar threads

  • Programming and Computer Science
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
234
  • Programming and Computer Science
Replies
5
Views
988
  • Programming and Computer Science
Replies
3
Views
811
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
261
  • Programming and Computer Science
Replies
18
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
7
Views
428
Back
Top