-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
54 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
profile = janestreet | ||
version = 0.26.2 | ||
margin = 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
let count_factors_tail n = | ||
let rec aux i count = | ||
if i * i > n then count | ||
else if n mod i = 0 then aux (i + 1) (count + if i * i = n then 1 else 2) | ||
if i * i > n | ||
then count | ||
else if n mod i = 0 | ||
then aux (i + 1) (count + if i * i = n then 1 else 2) | ||
else aux (i + 1) count | ||
in | ||
if n <= 0 then 0 else aux 1 0 | ||
;; | ||
|
||
let find_triangular_with_divisors_tail target = | ||
let rec aux n tri_num = | ||
let factors_count = count_factors_tail tri_num in | ||
if factors_count > target then tri_num else aux (n + 1) (tri_num + n + 1) | ||
in | ||
aux 1 1 | ||
;; | ||
|
||
let result = find_triangular_with_divisors_tail 500 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters