Skip to content

Instantly share code, notes, and snippets.

@MZAWeb
Created August 30, 2012 00:08
Show Gist options
  • Select an option

  • Save MZAWeb/3520778 to your computer and use it in GitHub Desktop.

Select an option

Save MZAWeb/3520778 to your computer and use it in GitHub Desktop.
Eurler 2 (not tested)
unsigned int dd_eurler_2(){
int a = 1;
int b = 2;
int sum = 0, response = 0;
for ( int i=0; a<4000000; i++ ) {
sum = a + b;
a = b;
b = sum;
if ( a % 2 == 0 ){
response+=a;
}
}
return response;
}
<?php
$a = 1;
$b = 2;
$sum = 0;
$response = 0;
for ( $i=0; $a<4000000; $i++ ) {
$sum = $a + $b;
$a = $b;
$b = $sum;
if ( $a % 2 == 0 ){
$response+=$a;
}
}
echo $response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment