Request #02
This seems to be right formula for the series.
A[n] : Σ[k:=1..n] k = (n + 1) * n / 2
So, let's proove by mathematical induction.
1/ A[1] = (1 + 1) * 1 / 2 = 1 ;* likewise: A[2] = 3, A[3] = 6,…, and even A[0] = 0 2/ A[k + 1] = A[k] + (k + 1) = (k + 1) * k / 2 + k + 1 = (k**2 + 3k + 2) / 2 = (k + 2) * (k + 1) / 2 = A[k + 1] ;* q.e.d.
What nice toys we have, to show it like this!
% function { local n; n="${1}"; shift; ocaml -e 'open List;; print_newline (); let n = '"${n}"' in ↪ print_int (int_of_float (floor ((float_of_int (n + 1)) *. (float_of_int n) /. 2.0))) ; print_char (char_of_int 0x3b); print_newline (); ↪ print_int (fold_left (fun l r -> l + r) 0 (init '"${n}"' (fun i -> i + 1))); print_char (char_of_int 0x3b); print_newline (); print_newline ()'; ↪ } 1 1; 1; % function { local n; n="${1}"; shift; ocaml -e 'open List;; print_newline (); let n = '"${n}"' in ↪ print_int (int_of_float (floor ((float_of_int (n + 1)) *. (float_of_int n) /. 2.0))) ; print_char (char_of_int 0x3b); print_newline (); ↪ print_int (fold_left (fun l r -> l + r) 0 (init '"${n}"' (fun i -> i + 1))); print_char (char_of_int 0x3b); print_newline (); print_newline ()'; ↪ } 2 3; 3; % function { local n; n="${1}"; shift; ocaml -e 'open List;; print_newline (); let n = '"${n}"' in ↪ print_int (int_of_float (floor ((float_of_int (n + 1)) *. (float_of_int n) /. 2.0))) ; print_char (char_of_int 0x3b); print_newline (); ↪ print_int (fold_left (fun l r -> l + r) 0 (init '"${n}"' (fun i -> i + 1))); print_char (char_of_int 0x3b); print_newline (); print_newline ()'; ↪ } 3 6; 6; % function { local n; n="${1}"; shift; ocaml -e 'open List;; print_newline (); let n = '"${n}"' in ↪ print_int (int_of_float (floor ((float_of_int (n + 1)) *. (float_of_int n) /. 2.0))) ; print_char (char_of_int 0x3b); print_newline (); ↪ print_int (fold_left (fun l r -> l + r) 0 (init '"${n}"' (fun i -> i + 1))); print_char (char_of_int 0x3b); print_newline (); print_newline ()'; ↪ } 0 0; 0; % function { local n; n="${1}"; shift; ocaml -e 'open List;; print_newline (); let n = '"${n}"' in ↪ print_int (int_of_float (floor ((float_of_int (n + 1)) *. (float_of_int n) /. 2.0))) ; print_char (char_of_int 0x3b); print_newline (); ↪ print_int (fold_left (fun l r -> l + r) 0 (init '"${n}"' (fun i -> i + 1))); print_char (char_of_int 0x3b); print_newline (); print_newline ()'; ↪ } 100 5050; 5050; %