-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathp048.java
More file actions
47 lines (38 loc) · 779 Bytes
/
p048.java
File metadata and controls
47 lines (38 loc) · 779 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
37
38
39
40
41
42
43
44
45
46
47
import java.math.BigInteger;
/**
*
* @author gouravrusiya
*
*/
public class p048 {
public static void main(String[] args) {
// TODO Auto-generated method stub
BigInteger sum = new BigInteger("0");
BigInteger i = new BigInteger("1");
BigInteger x = new BigInteger("1");
//long sumAns = 0;
//int z = 0;
int y = 1;
int j = 1;
String s = "";
for(;j<=1000;j++)
{
x = i.pow(j);
sum = sum.add(x);
i = i.add(BigInteger.ONE);
}
String str = sum.toString();
//System.out.println(str);
int len = str.length()-1;
//System.out.println(len);
for(y=1;y<=10;y++)
{
s += str.charAt(len);
len--;
}
//System.out.println(s);
StringBuffer buf = new StringBuffer(s);
buf.reverse();
System.out.println(buf);
}
}