-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiscreteMaths.java
More file actions
60 lines (40 loc) · 1.12 KB
/
DiscreteMaths.java
File metadata and controls
60 lines (40 loc) · 1.12 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
public class DiscreteMaths {
public DiscreteMaths() {
}
public int sumX(int x[]) {
int totalX = 0;
for (int i = 0; i < x.length; i++)
totalX += x[i];
return totalX;
}
public int sumY(int y[]) {
int totalY = 0;
for (int i = 0; i < y.length; i++)
totalY += y[i];
return totalY;
}
public int sumXY(int x[], int y[] ) {
int totalXY = 0;
for (int i = 0; i < x.length; i++)
totalXY += x[i] * y[i];
return totalXY;
}
public int sumXSquare(int x[]) {
int totalXSquare = 0;
for (int i = 0; i < x.length; i++)
totalXSquare += x[i] * x[i];
return totalXSquare;
}
public int sumXCube(int x[]) {
int totalXCube = 0;
for (int i = 0; i < x.length; i++)
totalXCube += x[i] * x[i] * x[i];
return totalXCube;
}
public int sumXSquareY(int x[], int y[]) {
int totalXSquareY = 0;
for (int i = 0; i< x.length; i++)
totalXSquareY += x[i] * x[i] * y[i];
return totalXSquareY;
}
}