Question: ```
function isPrime(num) {
  let result = true;
  if (num < 2) {
    result = false;
    return result;
  }

  for (let i = 2; i < num; i++) {
    if (num % i === 0) {
      result = false;
      break;
    }

  }
  return result;
}

```

I am trying to find whether a given number is prime or not, why is my code not executing in a limited amount of time?

Answer: 
§6.7.6.3p5 "Function declarators (including prototypes) > Semantics":

> 
> If, in the declaration "**T D1**", **D1** has the form
> 
> 
> 
> > 
> > **D** **(** *parameter-type-list* **)**
> > 
> > 
> > 
> 
> 
> or
> 
> 
> 
> > 
> > **D** **(** *identifier-list*opt **)**
> > 
> > 
> > 
> 
> 
> and the type specified for *ident* in the declaration "**T D**" is "*derived-declarator-type-list T*", then the type specified for *ident* is "*derived-declarator-type-list* function returning the unqualified version of *T*"
> 
> 
> 

So the type of `foo` is the same as if it was declared `S foo(void)`.

See also §6.7.3p5 "Type qualifiers > Semantics":

> 
> The properties associated with qualified types are meaningful only for expressions that are lvalues.
> 
> 
> 

So even if the first quoted paragraph didn't change the type, the const-qualification of the non-lvalue expression `foo()` would not be meaningful
Undefined behavior?

> 
> **6.7.3 Type qualifiers**
>   
> ...
>   
> 
> 9 If the specification of an array type includes any type qualifiers, the element type is so qualified, not the array type. ***If the specification of a function type includes any type
> qualifiers, the behavior is undefined.***136)
> 

Or am I massively missing the point?