@glennyisbae/

ProjectEuler

Java

No description

fork
loading
Files
  • Main.java
Main.java
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
class Main {
  public static void main(String[] args) {
    //System.out.println("Fibonacci:"+fibonacci());
    System.out.println("Largest Prime Factor:"+largePrime());
	//System.out.println("10,001st Prime:"+$10001prime());
	//System.out.println("Big Plaindrome:"+palindrome());
  }
  public static long fibonacci(){
      long bill=0;
    long[]a={0,0,1};
    for (int i=0; a[0]<4000000L&& a[1]<4000000L&& a[2]<4000000L; i++){
        if (i%3==0)
        a[0]=a[1]+a[2];
        if (i%3==1)
        a[1]=a[0]+a[2];
        if (i%3==2)
        a[2]=a[1]+a[0];
        if (a[i%3]%2==0)
        bill+=a[i%3];
    }
    return (bill);
  }
  public static long largePrime(){
      long max=0L;
      boolean lock=true;
      for (long i=169L; i<600851475143L/2L; i+=2){
          lock=true;
          
          if (600851475143L%i==0L){
              
          for (long j=2L; j<(long)Math.sqrt(i); j++){
              if (i%j==0L){
             
              lock=false;
              }
          }
          
        if (lock)
        max=i;
        System.out.println(max);}
        
      }
    return max;
  }
  public static long $10001prime(){
	  long x=1; long y=1; boolean lock=true;
	  while (x!=10001){
		  y+=2;
		lock=true;
		for (long j=2L; j<y/2L; j++){
              if (y%j==0L){
             
              lock=false;
              }
          }
          
        if (lock)
        x++;
		  
	  }
	  return y;
  }
  public static long palindrome(){
	  long bill=0;
	  long jill=0;
	  long kill=0;
	  long ill=0;
	  for (long x=999; x>=0; x--){
		  for (long y=999; y>=100; y--){
			  jill=x*y;
			  bill=jill;
			  kill=0;
			  if (jill%10!=0)
				  while (jill!=0){
				  kill= (kill*10) + jill%10;
				  jill/=10;
				  
				  }
			  
			  if (kill==bill && kill>ill){
			  ill=kill;
			  
		  }
			}
		  }
		return ill;
	  }
  /*public static long squares(){
	  long bill=0;
	  for (long x=0; x<=100; x++){
		  bill+=Math.pow(x,2);
	  }
	  long jill=0;
	  for (long y=0; y<=100; y++){
		  jill+=y;
		  jill= Math.pow(jill,2);
	  }
  }*/
}