Educational code samples demonstrating basic loop structures in Java and Python.
https://github.com/davidbmar/exampleLoops · public · shipped
A minimal educational repository containing implementations of a simple multiplication table generator. It solves a specific algorithmic task: given an integer n, print the first 10 multiples of n using iterative loops. The project serves as a reference for syntax comparison between Java and Python.
javac Solution.java java Solution python3 loops.py
flowchart TD
A[User Input] -->|Integer n| B(Main Execution)
B --> C{Loop Counter 1-10}
C -->|Yes| D[Calculate n * counter]
D --> E[Print Formatted String]
E --> C
C -->|No| F[Exit]
The Java implementation uses the java.util.Scanner class for standard input parsing and a standard for-loop for iteration. The logic calculates products sequentially and prints formatted strings to stdout. The Python implementation (implied by description) follows similar logic using Python's range-based looping constructs.
sequenceDiagram
participant User
participant Main as Solution.main()
participant Scanner as java.util.Scanner
participant Console as System.out
User->>Main: Provide integer n
Main->>Scanner: nextInt()
Scanner-->>Main: Return n
loop counter = 1 to 10
Main->>Main: Calculate answer = n * counter
Main->>Console: println(n + " x " + counter + " = " + answer)
end
Use this repository as a baseline for teaching introductory programming concepts, specifically iteration and standard I/O. It is suitable for beginners learning syntax differences between statically typed (Java) and dynamically typed (Python) languages.
✓ all on main — nothing unmerged.