# ๐ 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