Set value in $form_state['storage'] seems to change before validation
I don't like the cache method as it is quite complicated. If cache method is the only way to do that. I would recommend using Session Cache API.

In this case, exposing the answer to the form and collecting it from $form_state['input'] would be my choice.

function mymodule_custom_form($form, &amp;$form_state) {
  $input = &amp;$form_state['input'];

  $number1 = rand(0, 10);
  $number2 = rand(0, 10);
  $form['numbercheck'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; 'Please fill in the sum of '. $number1 .' and '. $number2,
    '#required' =&gt; TRUE,
  );

  // hidden field is only hidden to user but you still can inspect it
  // from source. So hash function is used to encrypt here.
  $form['checksum'] = array(
    '#type' =&gt; 'hidden',
    '#value' =&gt; isset($input['checksum']) ? $input['checksum'] : hash('sha256', $number1 + $number2),
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Submit',
  );

  return $form;
}

function mymodule_custom_form_validate(&amp;$form, &amp;$form_state) {
  $hash = hash('sha256', $form_state['values']['numbercheck']);

  // compare the hash result.
  if ($form_state['values']['checksum'] != $hash) {
    form_set_error('numbercheck', 'The sum was not correct');  
  }
}