-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathp025.java
More file actions
41 lines (31 loc) · 763 Bytes
/
p025.java
File metadata and controls
41 lines (31 loc) · 763 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
import java.math.BigInteger;
/**
*
* @author gouravrusiya
*
*/
public class p025 {
public static void main(String[] args) {
// TODO Auto-generated method stub
long startTime = System.currentTimeMillis();
BigInteger a = new BigInteger("1");
BigInteger b = new BigInteger("1");
BigInteger c = new BigInteger("0");
//long n = 4000000L;
long i = 0;
for(i=3;;i++)
{
c= a.add(b);
String str = new String(c.toString());
//System.out.println(str);
int len = str.length();
if(len == 1000)
break;
a=b;
b=c;
}
System.out.println(i);
long endTime = System.currentTimeMillis();
System.out.println("Took "+(endTime - startTime) + " ms");
}
}