Problem with arduino code to activate a fan

Hello, I created a simple circuit with a RTD to measure temperature and activate a fan when a certain temperature higher than 305 degree is reached. I connected the fan to the source of a transistor and a resistance to its drain; the transistor is connected to a PWM pin of arduino.
Problem is the fan starts working once the temperature is reached but it doesn't stop once the temperature has decreased: this happens because the code stops at the line that activates the fan.
Here's the line:

if(temp>305) digitalWrite(6, HIGH);

I'm using Arduino Micro and the firmware is Arduino 1.6.1.

Does anyone know what my problem is??
Thanks

Please post your whole program not just a snippet

What about an "else"

If(temp>305){
digitalWrite(6,HIGH);
}
else{
digitalWrite(6,LOW);
}

It doesn't work either.. I also thought that it may be possible my Arduino MICRO doesn't have enough memory to run the code and so it stops once it arrives at the PWM line of the code. Is it reasonable?
By the way, here's the entire code:

int pinInput = A2;
int pinInput2 = A3;
int pinInput3 = 5;
float part, part2;
float volt, volt2;
float cinque=5.00;
float temp,tempOut;
float beta=4300.00;
float delta;
int i =0;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(6, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
part=analogRead(pinInput);
volt=part*(cinque/1024);
temp= 1/(   (1/298.15) + (1/beta)*log( ((volt)/((5.00-volt) ) ) ) );
part2=analogRead(pinInput2);
volt2=part2*(cinque/1024);
tempOut= 1/(   (1/298.15) + (1/beta)*log( ((volt2)/((5.00-volt2) ) ) ) );
Serial.println(temp);
delay(100);
//Serial.println(-(tempOut)*100);
delay(100);


if(temp>305) 
{digitalWrite(6, HIGH)}
else{
digitalWrite(6, LOW)}

if(temp<290) {
digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);              // wait 
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(100); 
 }
}

the real problem is the code stops because if I open the serial monitor while running the code I notice it stops writing values of temperature as soon as it reaches the 305 degrees that should start the fan.

The program that you posted will not compile because of missing semi-colons so it cannot be the program that you are running.