Re: The Project Euler thread
for all it's worth, here's my friend key: 83532459359302_e704d4c6b1d37a7739410f38da156b2a
for all it's worth, here's my friend key: 83532459359302_e704d4c6b1d37a7739410f38da156b2a
file = open('/path/to/file')
file.read() # Returns whole file.
file.readline() # Will return line by line.
file.readlines() # Returns a list of every line.
file.close() # Close the file after you have read everything you need.

while 1:
print "INDENT"
if "INDENT":
print "MORE INDENT"
print "NEVER REACHES HERE"



//this will be our final answer
int probSum = 0;
//at some point, the sum of the factorials of the digits won't be large enough to add up to the number
//so choose our digits to be 9 and find when we have too many digits
//our upper bound for curious numbers becomes k
int i = 1;
int nFact = factorial(9);
int k = 9;
while(i*nFact > k)
{
k += 9*Math.pow(10, i);
i++;
}
for(int j=10; j <=k ; j++)
{
String[] digits = (j+"").split("");
int sum = 0;
for(int l = 1; l < digits.length; l++)
{
sum += factorial(Integer.parseInt(digits[l]));
}
if(j==sum)
{
probSum += j;
}
}
System.out.println(probSum);
int totalScore = 0;
File file = new File("names.txt");
Scanner scan = null;
try
{
scan = new Scanner(file);
}
catch (FileNotFoundException e) {}
String nameString = scan.next();
String[] names = nameString.split("\",\"");
ArrayList<String> names2 = new ArrayList<String>();
for(int i = 0; i < names.length; i++)
{
names2.add(names[i]);
}
Collections.sort(names2);
for(int i = 0; i < names2.size(); i++)
{
char[] chars = names2.get(i).toCharArray();
int charSum = 0;
for(int j = 0; j < chars.length; j++)
{
charSum += chars[j] - 'A' + 1;
}
totalScore += charSum*(i+1);
}
System.out.println(totalScore);



$count = 0
$total = 0
do{if (($count % 3 -eq 0) -or ($count % 5 -eq 0))
{
$total = $total + $count
}
else
{
$total = $total
}
$count++
}
while ($count -lt 1000)
echo $total
$f0 = 0
$f1 = 1
$fsum = 0
do{
if ($f1 % 2 -eq 0)
{
$fsum = $fsum + $f1
}
if ($f0 % 2 -eq 0)
{
$fsum = $fsum + $f0
}
$f0 = $f0 + $f1
$f1 = $f1 + $f0
}
while ($f0 -lt 4000000)
echo $fsum

Comment