/** static factory constructor */ public static SmartNumber from(long aNum) { return new SmartNumber(aNum); }
Even numbers: 0, 2, 4, 6, 8, ... //Example Usage SmartNumber sn = new SmartNumber(12); println("Number is even: " + sn.isEven()); //Number is even: true sn = new SmartNumber(8097); println("Number is even: " + sn.isEven()); //Number is even: false
public String toString() { return "" + this.getNum(); }
//Example Usage SmartNumber sn = new SmartNumber(11); println("SmartNumber is: " + sn.getNum()); //SmartNumber is: 11
//Example Usage SmartNumber sn = new SmartNumber(11); println(sn.toString()); //11 sn.setNum(1003); println(sn.toString()); //1003
Even numbers: 0, 2, 4, 6, 8, ... //Example Usage SmartNumber sn = new SmartNumber(12); println("Number is even: " + sn.isEven()); //Number is even: true sn = new SmartNumber(8097); println("Number is even: " + sn.isEven()); //Number is even: false
Odd numbers: 1, 3, 5, 7, 9, ... //Example Usage SmartNumber sn = new SmartNumber(12); println("Number is even: " + sn.isOdd()); //Number is even: false sn = new SmartNumber(8097); println("Number is even: " + sn.isOdd()); //Number is even: true
//Given primitive integers "a" and "b" (either int or long) long q = Math.round((double)a / b);
Examples: 4/5 = 1 5/5 = 1 7/5 = 1 8/5 = 2 9/5 = 2 19/5 = 4 Example Use: SmartNumber sn = new SmartNumber(9); println("Result of 9/5 = " + sn.divideAndRound(5)); //Result of 9/5 = 2
First five squares:
First five cubes:
Number | Candidate Factor (Method Parameter) | isDivisibleBy |
---|---|---|
20 | 1 | true |
20 | 2 | true |
20 | 3 | false |
20 | 4 | true |
20 | 5 | true |
20 | 6 | false |
20 | 7 | false |
20 | 8 | false |
20 | 9 | false |
20 | 10 | true |
20 | 11 | false |
20 | etc | false |
Number | squared |
---|---|
1 | 1 |
2 | 4 |
3 | 9 |
4 | 16 |
5 | 25 |
Number | squared |
---|---|
1 | 1 |
2 | 8 |
3 | 27 |
4 | 64 |
5 | 125 |
Number | divisor Method Parameter | remainder |
---|---|---|
10 | 1 | 0 |
10 | 2 | 0 |
10 | 3 | 1 |
10 | 4 | 2 |
10 | 5 | 0 |
10 | 6 | 4 |
10 | 7 | 3 |
10 | 8 | 2 |
10 | 9 | 1 |
10 | 10 | 0 |
10 | 11 | 10 |
10 | 12 | 10 |
10 | 13 | 10 |
10 | 14 | 10 |
10 | 15 | 10 |
First eleven primes:
Number | isPalindrome | |
---|---|---|
1 | true | |
2 | true | |
10 | false | |
11 | true | |
107 | false | |
151 | true | |
87378 | true |
Number | Unique Factors | Factor Count |
---|---|---|
6 | 1, 2, 3, 6 | 4 |
9 | 1, 3, 9 | 3 |
11 | 1, 11 | 2 |
12 | 1, 2, 3, 4, 6, 12 | 6 |
30 | 1, 2, 3, 5, 6, 10, 15, 30 | 8 |
Number | Unique Prime Factors | Prime Factor Count |
---|---|---|
6 | 2, 3 | 2 |
9 | 3 | 1 |
11 | None | 0 |
12 | 2, 3 | 2 |
30 | 2, 3, 5 | 3 |
31 | None | 0 |
210 | 2, 3, 5, 7 | 4 |
4 * 3 * 2 * 1 = 24
10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 3628800
Number | factorJKZ |
---|---|
1 | 0 |
2 | 2 |
3 | 3 |
4 | 9 |
5 | 5 |
6 | 0 |
7 | 7 |
8 | 17 |
9 | 13 |
10 | 9 |
public String getSummary() { String summary = ""; String sep = System.lineSeparator(); summary += "Number: " + this.getNum() + sep; summary += "Prime: " + this.isPrime(); summary += "Factor Count: " + this.factorCount() + sep; summary += "Remainder(/10): " + this.remainder(10) + sep; //TODO return summary; }