学习内容:
JAVA:
package exercise;
public class _偶斐波那契数 {
public static void main(String[] args) {
int[] a = new int[500];
int sum = 0;
int var = 0;
a[0]=1;
a[1]=2;
for(int i=0;a[i]<4000000;i++) {
var = a[i]+a[i+1];
a[i+2] = var;
//System.out.println(a[i]);
if(a[i]%2==0) {
sum+=a[i];
}
}
System.out.println(sum);
}
}
C#:
#include<stdio.h>
//13195 = 5 * 7 * 13 *29
int main(){
long long num = 600851475143L;
int max = 0;
for(long long i = 2;i<=num ; i++){
if(num%i==0){
num /= i;
if(max < i) max = i;
}
}
printf("%d",max);
}
结果:6857