Skip to content

Instantly share code, notes, and snippets.

View afrieirham's full-sized avatar
🏠
Working from home

Afrie Irham afrieirham

🏠
Working from home
View GitHub Profile
@afrieirham
afrieirham / projecteuler7.py
Created January 26, 2019 09:36
Solution for Project Euler #7
def problem7():
i=2
count = 0
while(True):
if(isPrime(i)):
count += 1
if(count==10001):
print(i)
break
i += 1
@afrieirham
afrieirham / projecteuler6.py
Created January 26, 2019 09:00
Solution for Project Euler #6
def sumOfSqure(number):
total = 0
for i in range(1, number + 1):
total += i*i
return total
def squareOfSum(number):
total = 0
for i in range(1, number + 1):
total += i
@afrieirham
afrieirham / projecteuler5.py
Created January 26, 2019 08:37
Solution for Project Euler #5
def problem5():
i=20
while(True):
print(i)
if i%20==0 and i%19==0 and i%18==0 and i%17==0 and i%16==0 and i%15==0 and i%14==0 and i%13==0 and i%12==0 and i%11==0:
print(i)
break
i+= 20
@afrieirham
afrieirham / projecteuler2.java
Created January 26, 2019 07:10
Solution to Project Euler #2
public static void problem2(){
int a = 1;
int b = 2;
int c = 0;
List<Integer> even = new ArrayList<Integer>();
do{
c = a + b;
if(b%2==0){
@afrieirham
afrieirham / projecteuler1.java
Created January 26, 2019 07:06
Solution for Project Euler #1
public static void problem1(){
Set<Integer> multiples = new HashSet<Integer>();
for(int i=1; i<1000; i++){
if(i%3==0 || i%5==0){
multiples.add(i);
}
}
Integer[] numbers = multiples.toArray(new Integer[multiples.size()]);
@afrieirham
afrieirham / projecteuler4.py
Last active January 26, 2019 07:05
Solution to Project Euler #4
def isPalindrome(number):
string = str(number)
list = []
revList = []
i = 0;
while i<len(string):
list.append(string[i])
i += 1