答案:9227463(错误)
思想:
a,b,c,d,e,f,g,h,i --- s
+
b,c,d,e,f,g,h,i,j --- s-a+j
=
c,d,e,f,g,h,i,j,k --- s-a-b+j+k
所以s=k-b,k是大于等于4000000的第二个数,b=2
// Euler1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
int main(int argc, char* argv[])
{
int a=1,b=2;
int n=0;
int c;
while(true)
{
c=a+b;
if(c>4000000)
{
n++;
}
if(n==2)
{
break;
}
a=b;
b=c;
}
printf("%d", c-2);
return 0;
}