Hi there:
Do you think any of you could help me to make this UDF so when a 0 (zero) or 1 (one) is inputted it retrieves an "X" or any other character as the output? (since 0 and 1 are not prime nor composite numbers).
Well here is the UDF i want to be adapted.
Thanks a lot in advance!
Do you think any of you could help me to make this UDF so when a 0 (zero) or 1 (one) is inputted it retrieves an "X" or any other character as the output? (since 0 and 1 are not prime nor composite numbers).
Well here is the UDF i want to be adapted.
Code:
Function prime(num)
Dim j, k, remain As Integer
j = Int(num)
If j <> num Then
prime = "NonInt"
Exit Function
End If
j = Sqr(num)
For k = 2 To j
remain = num Mod k
If remain = 0 Then
prime = "NonPrime"
Exit Function
End If
Next k
prime = "Prime"
End Function
Thanks a lot in advance!