Alexan
Alexan

Reputation: 8637

get greatest prime factor in F#

I had VS 11 beta and the following code was working without problem:

let rec fac x y =
    if x = y then y
    elif x % y = 0I then fac (x / y) y
    else fac x / (y + 1I)

Now I installed VS 2012 RC and I get the following error:

The type 'System.Numerics.BigInteger -> System.Numerics.BigInteger' is not compatible with the type 'System.Numerics.BigInteger'

Is code not correct or F# interactive? It's F# 3.0.

EDIT:

Actually problem not in F#, but in my code, it should be:

else fac x (y + 1I)

I just saved wrong version, when I worked in VS 11.

Upvotes: 1

Views: 134

Answers (1)

Ramon Snir
Ramon Snir

Reputation: 7560

fac expects two numbers, so when you have fac x, it isn't a number and thus cannot be divided by a number.

Upvotes: 3

Related Questions