-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverse Coding.java
More file actions
36 lines (29 loc) · 853 Bytes
/
Reverse Coding.java
File metadata and controls
36 lines (29 loc) · 853 Bytes
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
//{ Driver Code Starts
//Initial Template for Java
import java.io.*;
import java.util.*;
class GFG {
public static void main(String args[]) throws IOException {
BufferedReader read =
new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(read.readLine());
while (t-- > 0) {
String S[] = read.readLine().split(" ");
int n = Integer.parseInt(S[0]);
Solution ob = new Solution();
System.out.println(ob.sumOfNaturals(n));
}
}
}
// } Driver Code Ends
//User function Template for Java
class Solution {
static int sumOfNaturals(int n) {
// code here
int num = n * (n + 1);
int res = num/2;
int checkValue = 1000000007;
res = res % checkValue;
return res;
}
};