I have very recently started to learn c, my first coding language. I am trying to solve problem 3 from Project Euler, and I wrote this to do so. This code is meant to identify the largest prime factor of 600851475143, but instead I get a strange return value I don't understand. Anyone know why?
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i = 1, a = 0, prime = 0;
for(i = 1; i < 600851475143; i += 2) {
for(a = 0; a <= i / 2; a++) {
if(i % a == 0) {
break;
}
if(a = i / 2) {
if(600851475143 % i == 0) {
prime = i;
}
}
}
}
printf("%d\n", prime );
return 0;
}