Logic building is about creating clear, step-by-step methods to solve problems using simple rules and principles. It’s the heart of coding, enabling programmers to think, reason, and arrive at smart solutions just like we do.
Here are some tips for improving your programming logic:
- Understand the problem: Read and understand the problem statement.
- Generate Examples: Create additional input and output cases for each problem.
- Draw observations: Draw observations and patterns based on the examples you created.
- Start with Basic: First, think of the basic way to solve the problem then optimize the solution.
Basic
- Check Even or Odd
- Multiplication Table
- Sum of Naturals
- Sum of Squares
- Swap Two Numbers
- Closest Number
- Dice Problem
Easy
- Sum of Digits
- Reverse Digits
- Prime Testing
- Check Power
- Overlapping Rectangles
- Factorial
- Pair Cube Count
- GCD or HCF
- LCM
- Perfect Number
- Add Two Fractions
- Day of the Week
- Nth Fibonacci
- Decimal to Binary
- N-th term of 1, 3, 6, 10, 15, 21…
- Armstrong Number
- Palindrome Number
- Digit Root
Medium
- Square Root
- 3 Divisors
- Divisibility by 11
- Divisibility by 13
- K-th Digit in a^b
- Fraction to Recurring Decimal
- Recurring Sequence in a Fraction
- Compute nPr
- Compute nCr
- Pascal’s Triangle
- All Factor (Or Divisors)
- Prime Factorization
- Largest Prime factor
- Modular Exponentiation
- nth Catalan Number
- Binomial Coefficient
- Power Set
Hard
- Sieve of Eratosthenes
- Super Prime
- Clock Angle
- Tower of Hanoi
- Rat and Poisoned
- 8 puzzle Problem
- Euler's Totient Function
- Josephus Problem
Recommended Links