Can I Create a Pattern with Alternating 1's and 0's in Mathematica?

  • Context: Mathematica 
  • Thread starter Thread starter Sarah rob
  • Start date Start date
  • Tags Tags
    Generator Mathematica
Click For Summary
SUMMARY

The discussion focuses on generating a pattern of alternating 1's and 0's in Mathematica using iterative functions. The user initially employs a counter variable 'co' to alternate between 10 1's and 10 0's. They seek to modify this approach to create a pattern of 10 1's followed by 5 0's. The proposed solution involves adjusting the modulus condition in the If statement to achieve the desired output.

PREREQUISITES
  • Understanding of Mathematica syntax and functions
  • Familiarity with iterative programming concepts
  • Knowledge of the Mod function in Mathematica
  • Basic programming logic for pattern generation
NEXT STEPS
  • Explore advanced Mathematica functions for pattern generation
  • Learn about the use of counters in iterative functions in Mathematica
  • Investigate the Mod function's applications in different contexts
  • Study examples of conditional statements in Mathematica for complex patterns
USEFUL FOR

Mathematica users, programmers interested in pattern generation, and anyone looking to enhance their skills in iterative functions and conditional logic within Mathematica.

Sarah rob
Messages
16
Reaction score
0
I am using
co = 0;
co++
If[Mod[co, 20, 1] > 10, 1, 0];
which is used in an iterative function
which produces 10 1' s 10 0' s, 10 1' s 10 0' s and so on ...
Could I use a similar method to produce 10 1' s then 5 0' s, 10 1's 5 0' s and so on...
 
Physics news on Phys.org
co = 5;co++;If[Mod[co, 20, 1] > 5, 1, 0]
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K