--- /dev/null
+(**************************************************************************)
+(* ___ *)
+(* ||M|| *)
+(* ||A|| A project by Andrea Asperti *)
+(* ||T|| *)
+(* ||I|| Developers: *)
+(* ||T|| A.Asperti, C.Sacerdoti Coen, *)
+(* ||A|| E.Tassi, S.Zacchiroli *)
+(* \ / *)
+(* \ / Matita is distributed under the terms of the *)
+(* v GNU Lesser General Public License Version 2.1 *)
+(* *)
+(**************************************************************************)
+
+include "nat/factorization.ma".
+
+let rec factorize_aux2 i n b on b ≝
+ match b with
+ [ O ⇒ nfa_zero
+ | S b' ⇒
+ let p ≝ nth_prime i in
+ match p_ord n p with
+ [ pair q r ⇒
+ match r with
+ [ O ⇒ nfa_zero
+ | S r' ⇒
+ match r' with
+ [ O ⇒
+ match q with
+ [ O ⇒ nfa_one
+ | _ ⇒ nfa_proper (nf_last (pred q))]
+ | S _ ⇒
+ let res ≝ factorize_aux2 (S i) r b' in
+ match res with
+ [ nfa_zero ⇒ nfa_zero (* impossible *)
+ | nfa_one ⇒ nfa_proper (nf_last q)
+ | nfa_proper l ⇒ nfa_proper (nf_cons q l)]]]]].
+
+definition factorize2 ≝ λn.factorize_aux2 0 n n.
\ No newline at end of file