# π Day 25 of My Automation Journey β Deep Dive into Logic π (Part 2)
Continuing from earlier, here are the remaining core number programs with full step-by-step explanations to strengthen logic building π πΉ 6. Divisors of a Number β Correct Logic π» Program: int u...

Source: DEV Community
Continuing from earlier, here are the remaining core number programs with full step-by-step explanations to strengthen logic building π πΉ 6. Divisors of a Number β Correct Logic π» Program: int user = 15; for(int i = 1; i <= user; i++) { if(user % i == 0) System.out.println(i); } π§ Logic Explained: user % i == 0 means: π βCan i divide user without remainder?β Loop runs from 1 β 15 π Step-by-Step Trace: i 15 % i Result 1 0 β
Print 2 1 β 3 0 β
4 3 β 5 0 β
15 0 β
π€ Output: 1 3 5 15 π‘ Key Insight: π Divisors are numbers that perfectly divide the given number πΉ 7. Count of Divisors π» Program: int user = 15; int count = 0; for(int i = 1; i <= user; i++) { if(user % i == 0) count++; } System.out.println(count); π§ Logic Explained: Same logic as divisors Instead of printing β we count π Example: Divisors of 15 β 1, 3, 5, 15 π Count = 4 π€ Output: 4 π‘ Key Insight: π Reuse logic + add counter β powerful pattern πΉ 8. Count of Digits π» Program: int user = 12345; int count = 0