Advertisement
JeffGrigg

Untitled

Nov 3rd, 2022
3,166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.48 KB | None | 0 0
  1. public class ConsoleProgramSample {
  2.  
  3.     public static void main(String[] args) {
  4.         for (int n = 1; n < 10000; ++n) {
  5.             System.out.print("n = " + n + ", output = ");
  6.             final var total = total(n);
  7.             System.out.println(total);
  8.         }
  9.     }
  10.  
  11.     private static int total(int a) {
  12.         int sum = 0;
  13.         for (int rem = 1; rem <= a; rem++) {
  14.             if (a % rem == 0)
  15.                 sum++;
  16.         }
  17.         return sum;
  18.     }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement