COMP2396
Loading...
Searching...
No Matches
Question2 Class Reference

Static Public Member Functions

static int d (int n)
 
static int digit_sum (int n)
 
static boolean is_self_number (int n)
 
static void main (String[] args) throws IOException
 

Detailed Description

Definition at line 3 of file Question2.java.

Member Function Documentation

◆ d()

static int Question2.d ( int n)
inlinestatic

Definition at line 12 of file Question2.java.

12 {
13 return n + digit_sum(n);
14 }
static int digit_sum(int n)
Definition Question2.java:4

References digit_sum().

Referenced by is_self_number().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ digit_sum()

static int Question2.digit_sum ( int n)
inlinestatic

Definition at line 4 of file Question2.java.

4 {
5 int sum = 0;
6 while (n > 0) {
7 sum += n % 10;
8 n /= 10;
9 }
10 return sum;
11 }

Referenced by d().

Here is the caller graph for this function:

◆ is_self_number()

static boolean Question2.is_self_number ( int n)
inlinestatic

Definition at line 15 of file Question2.java.

15 {
16 for (int i = 1; i < n; i++) {
17 if (d(i) == n) {
18 return false;
19 }
20 }
21 return true;
22 }
static int d(int n)

References d().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

static void Question2.main ( String[] args) throws IOException
inlinestatic

Definition at line 23 of file Question2.java.

23 {
24 InputStreamReader reader = new InputStreamReader(System.in);
25 BufferedReader buffer = new BufferedReader(reader);
26 int n = Integer.parseInt(buffer.readLine());
27 for (int i = 1; i < n; i++) {
28 if (is_self_number(i)) {
29 System.out.println(i);
30 }
31 }
32 }
static boolean is_self_number(int n)

References is_self_number().

Here is the call graph for this function:

The documentation for this class was generated from the following file: