Number Operations (Sum, Count, Reverse) Using Loop in Java
<ol> <li>Sum of Digits</li> </ol> <p><strong>java</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight java"><code><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Main</span> <span class="o">{</span> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="nc">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span> <span class="kt">int</span> <span class="n">num</span> <span class="o">=</span> <span class="mi">1234</span><span class="o">,</span> <span class="n">sum</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="k">while</span> <
- Sum of Digits
java
public class Main { public static void main(String[] args) { int num = 1234, sum = 0;public class Main { public static void main(String[] args) { int num = 1234, sum = 0;while (num > 0) { sum += num % 10; num =num/ 10; }
System.out.println("Sum = " + sum); } }`
Enter fullscreen mode
Exit fullscreen mode
output
- Count of Digits
java
public class Main { public static void main(String[] args) { int num = 1234, count = 0;public class Main { public static void main(String[] args) { int num = 1234, count = 0;while (num > 0) { num =num/ 10; count++; }
System.out.println("Count = " + count); } }`
Enter fullscreen mode
Exit fullscreen mode
output
- Reverse a Number
public class Main { public static void main(String[] args) { int num = 1234, rev = 0;public class Main { public static void main(String[] args) { int num = 1234, rev = 0;while (num > 0) { rev = rev * 10 + num % 10; num =num/ 10; }*
System.out.println("Reverse = " + rev); } }`
Enter fullscreen mode
Exit fullscreen mode
output
DEV Community
https://dev.to/vidya_cdd37fca763a53a10e2/number-operations-sum-count-reverse-using-loop-in-java-1epkSign in to highlight and annotate this article

Conversation starters
Daily AI Digest
Get the top 5 AI stories delivered to your inbox every morning.
Knowledge Map
Connected Articles — Knowledge Graph
This article is connected to other articles through shared AI topics and tags.
More in Products

Trading places: What happens when neuroscience turns into machine learning, and machine learning turns into neuroscience? - The Transmitter
Trading places: What happens when neuroscience turns into machine learning, and machine learning turns into neuroscience? The Transmitter

RIFT: Entropy-Optimised Fractional Wavelet Constellations for Ideal Time-Frequency Estimation
arXiv:2501.15764v3 Announce Type: replace Abstract: We introduce a new method for estimating the Ideal Time-Frequency Representation (ITFR) of complex nonstationary signals. The Reconstructive Ideal Fractional Transform (RIFT) computes a constellation of Continuous Fractional Wavelet Transforms (CFWTs) aligned to different local time-frequency curvatures. This constellation is combined into a single optimised time-frequency energy representation via a localised entropy-based sparsity measure, designed to resolve auto-terms and attenuate cross-terms. Finally, a positivity-constrained Lucy-Richardson deconvolution with total-variation regularisation is applied to estimate the ITFR, achieving auto-term resolution comparable to that of the Wigner-Ville Distribution (WVD), yielding the high-res

EpiDroid: Dependency-Guided Recomposition for Deep State Discovery in Mobile GUI Testing
arXiv:2604.01522v1 Announce Type: new Abstract: The increasing scale and complexity of mobile applications make automated GUI exploration essential for software quality assurance. However, existing methods often neglect state dependencies between test fragments, which leads to redundant exploration and prevents access to deep application states. We introduce EpiDroid, a black-box, pluggable framework that augments existing explorers through semantic state dependency awareness. EpiDroid distills raw traces into stable test fragments to extract underlying dependencies. It then employs a Recomposition-Replay paradigm to perform impact reasoning via LLM and deterministic replay on high-value mutable state elements. Through iterative feedback, EpiDroid refines the state-dependency graph to syst

Are Benchmark Tests Strong Enough? Mutation-Guided Diagnosis and Augmentation of Regression Suites
arXiv:2604.01518v1 Announce Type: new Abstract: Benchmarks driven by test suites, notably SWE-bench, have become the de facto standard for measuring the effectiveness of automated issue-resolution agents: a generated patch is accepted whenever it passes the accompanying regression tests. In practice, however, insufficiently strong test suites can admit plausible yet semantically incorrect patches, inflating reported success rates. We introduce STING, a framework for targeted test augmentation that uses semantically altered program variants as diagnostic stressors to uncover and repair weaknesses in benchmark regression suites. Variants of the ground-truth patch that still pass the existing tests reveal under-constrained behaviors; these gaps then guide the generation of focused regression


Discussion
Sign in to join the discussion
No comments yet — be the first to share your thoughts!