Skip to content

Instantly share code, notes, and snippets.

View goyuninfo's full-sized avatar

goyun.info goyuninfo

View GitHub Profile
@goyuninfo
goyuninfo / Project-Euler-5.java
Created May 20, 2014 22:29
Project Euler Smallest multiple
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 };
sum1,sum2=0,0
for i in range(100):
sum1+=(i+1)*(i+1)
sum2+=i+1
print sum2*sum2-sum1
@goyuninfo
goyuninfo / gist:64c973ad110f515b58ae
Created May 21, 2014 22:24
Project-Euler-6a.py
sum1=0
for i in range(100):
sum1+=(i+1)*(i+1)
print 10000*101*101/4-sum1
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
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
'''
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)) ))
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
@goyuninfo
goyuninfo / Project-Euler-10.py
Created May 26, 2014 03:03
Problem 10. Sum all primes below N million
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):
@goyuninfo
goyuninfo / Project-Euler-11.java
Created May 26, 2014 21:51
Project Euler PROBLEM 11 Largest product in a grid
package euler;
/**
*
* @author i88.ca
*/
public class ProjectEuler1 {
public static void main(String[] args) {
int[][] SQUARE = {
@goyuninfo
goyuninfo / Project-Euler-14.java
Created May 27, 2014 18:21
Project Euler 14: Longest Collatz Sequence
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;