-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBasicMan.java
More file actions
59 lines (47 loc) · 1.05 KB
/
BasicMan.java
File metadata and controls
59 lines (47 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package edu.Numbers;
import java.math.BigInteger;
public class BasicMan {
/**
* this class review the basic number manipulation for real numbers.
*
*/
public static void addition(){
//try big integer
int max = -1;
String maxstr = Integer.toString(max)+"00000";
BigInteger bi = new BigInteger(maxstr);
System.out.println(bi.multiply(new BigInteger(maxstr)));
System.out.println(bi);
}
//input should be i,j,j
public static int multi(int i,int j,int result){
if(i==1){
return result;
}
if(i==0||j==0){
return 0;
}
if(i%2==1){
return multi(i/2,j*2,result+2*j);
} else {
return multi(i/2,j*2,result+j);
}
}
/*
* if x = 0: return (q; r) = (0; 0)
(q; r) = divide(x/2; y)
q = 2 * q; r = 2 * r
if x is odd: r = r + 1
if r >= y: r = r - y; q = q + 1
*/
public static void divide(int x, int y){
int[] remain = {0,0};
}
public static void modularEx(){
}
public static void main(String[] args) {
// TODO Auto-generated method stub
addition();
System.out.println(multi(11,13,13));
}
}