This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package euler; | |
/** | |
* @author i88.ca | |
* | |
*/ | |
public class P5 { | |
// refers to overview in project Euler. | |
public static void main(String[] args) { | |
int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum1,sum2=0,0 | |
for i in range(100): | |
sum1+=(i+1)*(i+1) | |
sum2+=i+1 | |
print sum2*sum2-sum1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum1=0 | |
for i in range(100): | |
sum1+=(i+1)*(i+1) | |
print 10000*101*101/4-sum1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def isPrime(n): | |
i=2 | |
while i<=math.sqrt(n): | |
if n%i==0: | |
return 0 | |
i=i+1 | |
return 1 | |
i=3 | |
c=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def isPrime(n): | |
i=2 | |
while i<=math.sqrt(n): | |
if n%i==0: | |
return 0 | |
i=i+1 | |
return 1 | |
i=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Created on May 23, 2014 | |
@author: it.i88.ca | |
''' | |
from functools import reduce | |
def pro(s): | |
return reduce(lambda x,y:x*y, list(int(s[i]) for i in range(len(s)) )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for a in range(1,333): | |
blimit=int((1000-a)/2) | |
for b in range(a,blimit): | |
c=1000-a-b | |
if a*b+1000*c==500000: | |
print(a*b*c) | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def isPrime(n): | |
sqrt=int(math.sqrt(n)) | |
for i in range(2,sqrt+1): | |
if n%i==0: | |
return 0 | |
return 1 | |
s=2+3 | |
n=int((2000000-1)/6) | |
for i in range(1,n+1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package euler; | |
/** | |
* | |
* @author i88.ca | |
*/ | |
public class ProjectEuler1 { | |
public static void main(String[] args) { | |
int[][] SQUARE = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ca.i88.it.euler; | |
public class ProjectEuler14 { | |
public static void main(String[] args) { | |
long start = System.currentTimeMillis(); | |
final int number = 1000000; | |
int sequenceLength = 0; | |
int startingNumber = 0; |