Beginner to Mathematica's question using Module

  • Context: Mathematica 
  • Thread starter Thread starter psb01080
  • Start date Start date
  • Tags Tags
    Beginner module
Click For Summary
SUMMARY

The discussion focuses on defining a function f(n) in Mathematica that counts the number of zeros in a positive integer n. The user intends to utilize the functions "Module", "Mod", "Count", and "Floor" to achieve this, despite acknowledging that "IntegerDigits" and "Count" could provide a quicker solution. The suggested approach involves first drafting a general algorithm, implementing it in a Mathematica notebook, and then encapsulating the logic within a Module for finalization.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of the "Module" function in Mathematica
  • Knowledge of "Count" and "IntegerDigits" functions
  • Basic algorithm design skills
NEXT STEPS
  • Research how to implement the "Module" function in Mathematica
  • Learn about the "Count" function and its applications in Mathematica
  • Explore the "IntegerDigits" function for digit manipulation
  • Study algorithm design principles for counting algorithms
USEFUL FOR

Mathematica users, algorithm enthusiasts, and anyone interested in programming functions to manipulate integers and count specific digits.

psb01080
Messages
2
Reaction score
0
Okay, this is the question that i need to solve using mathematica:

Define the function f(n) which counts the number of zeros in n if n is the integer greater than 0.
If you input 105, 1005, 10005, find f(n).


I want to use Module in this question and I just found out that i have to use "Mod", "Count" and "Floor" but still haven't figured out this. Please help!
 
Physics news on Phys.org
Of course, IntegerDigits and Count would solve the question right away, but I suppose that's no fun :smile:

Anyway, I suggest first trying to write down a general algorithm, then programming it in a Mathematica notebook, and only in the final step putting it all in one module. For example, how would you use the functions you quoted to get the i-th digit?
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 8 ·
Replies
8
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
5K
Replies
1
Views
2K
  • · Replies 15 ·
Replies
15
Views
5K