1 year ago

#191012

test-img

Artique

Induction proof of Perfect number

fun perfect(n) =
  let 
    fun add_factors(n) =
      let 
        fun f(i) =
          if n mod i = 0 then i
          else 0;
              
        fun sum(a, b) =
          if a > b then 0
          else f(b) + sum(a, b-1);
      in 
        sum(1, n div 2)
      end;
  in 
    n = add_factors(n)
  end;

How to prove this by induction or invariant?

Correct me if I am wrong, but the Time complexity would be O(logn) and the Space complexity would be 1.

algorithm

sml

proof

induction

proof-of-correctness

0 Answers

Your Answer

Accepted video resources