]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/project-euler/255/255.factor
project-euler: Rewrap, update links, add copyrights, tests
[factor.git] / extra / project-euler / 255 / 255.factor
index 7d42607771aa1fb729a8ed95a8e745152474f3ae..121dc14cf0b3c15829102c158fe6fed529e9895a 100644 (file)
@@ -3,16 +3,16 @@
 USING: kernel math math.functions project-euler.common ;
 IN: project-euler.255
 
-! https://projecteuler.net/index.php?section=problems&id=255
+! https://projecteuler.net/problem=255
 
 ! DESCRIPTION
 ! -----------
 
-! We define the rounded-square-root of a positive integer n as the square root
-! of n rounded to the nearest integer.
+! We define the rounded-square-root of a positive integer n as
+! the square root of n rounded to the nearest integer.
 
-! The following procedure (essentially Heron's method adapted to integer
-! arithmetic) finds the rounded-square-root of n:
+! The following procedure (essentially Heron's method adapted to
+! integer arithmetic) finds the rounded-square-root of n:
 
 !     Let d be the number of digits of the number n.
 !     If d is odd, set x_(0) = 2×10^((d-1)⁄2).
@@ -22,27 +22,30 @@ IN: project-euler.255
 
 !     until x_(k+1) = x_(k).
 
-! As an example, let us find the rounded-square-root of n = 4321.
-! n has 4 digits, so x_(0) = 7×10^((4-2)⁄2) = 70.
+! As an example, let us find the rounded-square-root of n =
+! 4321. n has 4 digits, so x_(0) = 7×10^((4-2)⁄2) = 70.
 
 !     [ see URL for figure ]
 
 ! Since x_(2) = x_(1), we stop here.
 
-! So, after just two iterations, we have found that the rounded-square-root of
-! 4321 is 66 (the actual square root is 65.7343137…).
+! So, after just two iterations, we have found that the
+! rounded-square-root of 4321 is 66 (the actual square root is
+! 65.7343137…).
 
-! The number of iterations required when using this method is surprisingly low.
-! For example, we can find the rounded-square-root of a 5-digit integer
-! (10,000 ≤ n ≤ 99,999) with an average of 3.2102888889 iterations (the average
-! value was rounded to 10 decimal places).
+! The number of iterations required when using this method is
+! surprisingly low. For example, we can find the
+! rounded-square-root of a 5-digit integer (10,000 ≤ n ≤ 99,999)
+! with an average of 3.2102888889 iterations (the average value
+! was rounded to 10 decimal places).
 
-! Using the procedure described above, what is the average number of iterations
-! required to find the rounded-square-root of a 14-digit number
-! (10^(13) ≤ n < 10^(14))? Give your answer rounded to 10 decimal places.
+! Using the procedure described above, what is the average
+! number of iterations required to find the rounded-square-root
+! of a 14-digit number (10^(13) ≤ n < 10^(14))? Give your answer
+! rounded to 10 decimal places.
 
-! Note: The symbols ⌊x⌋ and ⌈x⌉ represent the floor function and ceiling
-! function respectively.
+! Note: The symbols ⌊x⌋ and ⌈x⌉ represent the floor function and
+! ceiling function respectively.
 
 ! SOLUTION
 ! --------