Skip to content

Instantly share code, notes, and snippets.

import sys
from string import split
f=open(sys.argv[1])
content=f.read()
print content
print 'the no.of lines in file = '+ str(len(split(content,'\n')))
@russelnickson
russelnickson / projecteuler_prob_20.py
Created December 1, 2009 19:49
n! means n (n 1) ... 3 2 1 Find the sum of the digits in the number 100! ??
a=100
b=0
f1=1
while a>1:
f1=a*f1
a-=1
f=f1
while f:
b=b+f%10
f/=10
@russelnickson
russelnickson / projecteuler_prob_16.py
Created December 1, 2009 19:43
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000??
a=2**1000
b=0
while a:
b=b+a%10
a/=10
print b
@russelnickson
russelnickson / projecteuler_prob_3.py
Created December 1, 2009 19:40
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?
a=600851475143
i=2
while i<a :
if a%i==0:
a1=a/i
else :
i+=1
continue
n=2