]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/project-euler/026/026.factor
project-euler: Rewrap, update links, add copyrights, tests
[factor.git] / extra / project-euler / 026 / 026.factor
index 0a7ec11d85856b9843ede7d56652318668d30baf..c44a74a6cb76b25f04db3d09531765a5eb905e71 100644 (file)
@@ -4,13 +4,14 @@ USING: kernel math math.functions math.primes
 project-euler.common sequences ;
 IN: project-euler.026
 
-! https://projecteuler.net/index.php?section=problems&id=26
+! https://projecteuler.net/problem=26
 
 ! DESCRIPTION
 ! -----------
 
-! A unit fraction contains 1 in the numerator. The decimal representation of
-! the unit fractions with denominators 2 to 10 are given:
+! A unit fraction contains 1 in the numerator. The decimal
+! representation of the unit fractions with denominators 2 to 10
+! are given:
 
 !     1/2  =  0.5
 !     1/3  =  0.(3)
@@ -22,11 +23,11 @@ IN: project-euler.026
 !     1/9  =  0.(1)
 !     1/10 =  0.1
 
-! Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. It can be
-! seen that 1/7 has a 6-digit recurring cycle.
+! Where 0.1(6) means 0.166666..., and has a 1-digit recurring
+! cycle. It can be seen that 1/7 has a 6-digit recurring cycle.
 
-! Find the value of d < 1000 for which 1/d contains the longest recurring cycle
-! in its decimal fraction part.
+! Find the value of d < 1000 for which 1/d contains the longest
+! recurring cycle in its decimal fraction part.
 
 
 ! SOLUTION
@@ -50,7 +51,8 @@ PRIVATE>
     swap 1 (mult-order) ;
 
 : period-length ( a/b -- n )
-    dup recurring-period? [ denominator 10 swap mult-order ] [ drop 0 ] if ;
+    dup recurring-period?
+    [ denominator 10 swap mult-order ] [ drop 0 ] if ;
 
 <PRIVATE