Inspired by the Euler problem #13, I dug out one of my old
Forth systems after a long time. See below for the solution.
Can you do the same in your Forth system?
Inspired by the Euler problem #13, I dug out one of my old
Forth systems after a long time. See below for the solution.
Can you do the same in your Forth system?
MinForth 3.6 (32 bit)
# fload euler13.mf
5537376230. solution: 5537376230. ok
This was made possible by a) high fp stack depth > 100, and
b) overflow when recognising integers (eg. within >NUMBER)
is treated as non-recognition, so the parsed string is passed
on to fp literal recognition.
Strictly speaking, this is obviously not a solution but an
approximation. Do you know a real solution, perhaps even
without loading a fat bignum library?
The program euler13.mf:
\ Work out the first ten digits of the sum of the
\ following one-hundred 50-digit numbers.
My first similar idea was:
50 decimal digits are equivalent to 167 binary digits. So splitting
the numbers in half would allow the use double number arithmetic
of a 64-bit Forth system for each half column.
I'm no mathematician and don't understand Paul's or Ron's
solutions. Assuming the phrase 'the first 10 digits" means the 10 most significant digits of the sum of the 100 numbers I think I would
My, this is cute! READ-NUMBERS using REFILL while including the file
(which uses REFILL itself)!
My, this is cute! READ-NUMBERS using REFILL while including the file
(which uses REFILL itself)!
To give credit where credit is due, Ron's solution follows a similar
path (although I have to admit that the ultra-compact 8th code looks
rather cryptic to me).
s 10 s:lsub . cr
Yeah for #13, I would just add up the leftmost 14 or so digits of each
number as 64-bit ints, then check that the result was not anywhere near causing an overflow in the top 10 digits. In the unlikely case where
that is an issue, use multi-precision.
Paul Rubin wrote:conversion
Yeah for #13, I would just add up the leftmost 14 or so digits of each
number as 64-bit ints, then check that the result was not anywhere near
causing an overflow in the top 10 digits. In the unlikely case where
that is an issue, use multi-precision.
I did check that with quad precision floats:
MinForth 3.6 (64 bit) (fp 128 bit)
# fload euler13.mf
5537376230. answer: 5537376230. ok
#
However even 112 mantissa bits are not sufficient for lossless
of integers with 50 decimal digits.
However even 112 mantissa bits are not sufficient for lossless conversion
of integers with 50 decimal digits.
M of the worst possible sets of LSBs? There has to be some arithmetic
rule that explains this. (There are people who have worked out all
of the Euler problems with pencil and paper).
-marcel--
Strictly speaking, this is obviously not a solution but an
approximation. Do you know a real solution, perhaps even
without loading a fat bignum library?
Gerry Jackson <do-not-use@swldwa.uk> writes:
I'm no mathematician and don't understand Paul's or Ron's
solutions. Assuming the phrase 'the first 10 digits" means the 10 most
significant digits of the sum of the 100 numbers I think I would
Wait what, I think I have #13 as the wrong problem? Yes, I had a saved >euler13.fs file that I posted, but it was actually for problem 14. Not
sure how that happened, sorry.
Yeah for #13, I would just add up the leftmost 14 or so digits of each
number as 64-bit ints, then check that the result was not anywhere near >causing an overflow in the top 10 digits. In the unlikely case where
that is an issue, use multi-precision. Or in a language with native
bignums, the whole thing becomes trivial.
Gerry Jackson's answer inspired my solution: sum up each column, the
way you would do it by hand. This not only avoids the need for
bignums and the uncertainty about the correctness that some of the
other solutions have, it is also the most efficient
Anton Ertl wrote:
Gerry Jackson's answer inspired my solution: sum up each column, the
way you would do it by hand. This not only avoids the need for
bignums and the uncertainty about the correctness that some of the
other solutions have, it is also the most efficient
Your solution is good.
I had toyed with the idea of building a tiny bignum library myself.
Binary operations, and with intrinsics, addition/subtraction are also >trivial. Multiplication wouldn't be difficult either, for division
the shift-subtract algorithm would be sufficient for me. Let's see,
maybe something for the next rainy season... ;-)
minforth <minforth@gmx.net> wrote:
I had toyed with the idea of building a tiny bignum library myself.
Binary operations, and with intrinsics, addition/subtraction are also >>trivial. Multiplication wouldn't be difficult either, for division
the shift-subtract algorithm would be sufficient for me. Let's see,
maybe something for the next rainy season... ;-)
The modulo operation is a real hassle. (We did it for the transputer.)
Gerry Jackson's answer inspired my solution: sum up each column, the
way you would do it by hand. This not only avoids the need for
bignums and the uncertainty about the correctness that some of the
other solutions have, it is also the most efficient: In this digitwise >solution, every digit is only added, while in the conversion
solutions, each digit costs at least an add, a subtract, and a
multiply (and more in the case of FP); my solution does the subtracts
for the whole column once instead of 100 times:
s" euler13.input" slurp-file 2constant input
: sumcolumn ( ucarry1 c-addr -- ucarry2 )
5100 bounds ?do
i c@ +
51 +loop
'0' 100 * - 0 # drop ;
: sum ( -- c-addr2 u2 )
0 <<#
input drop 50 1 mem-do
i sumcolumn
loop
0 #s #> ;
sum drop 10 type cr
This outputs "5537376230".
My, this is cute! READ-NUMBERS using REFILL while including the file
(which uses REFILL itself)!
Wait what, I think I have #13 as the wrong problem? Yes, I had a saved euler13.fs file that I posted, but it was actually for problem 14. Not
sure how that happened, sorry.
DBEGIN ( dn -- )
D 2CONSTANT bigsum
On 5/2/24 16:14, minforth wrote:
My first similar idea was:
50 decimal digits are equivalent to 167 binary digits. So splitting
the numbers in half would allow the use double number arithmetic
of a 64-bit Forth system for each half column.
Here's the first part of this to read in the numbers into an array, as
double length integers on a 64-bit Forth system (kforth64).
-- Krishna
=== begin code ===
\ euler13.4th
\
\ Work out the first ten digits of the sum of the
\ following one-hundred 50-digit numbers.
1 CELLS 8 < ABORT" Needs 64-bit Forth!"
10 constant LF
100 constant N
 50 constant Ndig
create $nums N Ndig * allot
create Dnums[ N 2* 16 * allot
: ]D@ ( a idx -- ud ) 16 * + 2@ ;
: ]D! ( ud a idx -- ) 16 * + 2! ;
: $>ud ( a u -- ud )Â 0 s>d 2swap >number 2drop ;
: $>2ud ( a u -- ud_low ud_high )
  drop Ndig 2/ 2dup + over $>ud 2swap $>ud ;
\ Read N big numbers as strings and then parse into
\ double length array
: read-numbers ( -- )
   N 0 DO
       refill IF
         LF parse dup Ndig <> ABORT" String Length Error!"
         $nums Ndig I * + swap move
       ELSE ABORT
       THEN
   LOOP
   N 0 DO
     $nums Ndig I * + Ndig
     $>2ud Dnums[ I 2* 1+ ]D! Dnums[ I 2* ]D!
   LOOP ;
\ read into array of 2*N doubles
read-numbers
37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 74324986199524741059474233309513058123726617309629
...
=== end code ===
And, here's the check to ensure the numbers loaded into the array Dnums[
=== test above code ===
include euler13
 ok
Dnums[ 0 ]D@ ud.
8220837590246510135740250Â ok
Dnums[ 1 ]D@ ud.
3710728753390210279879799Â ok
Dnums[ 2 ]D@ ud.
4896970078050417018260538Â ok
Dnums[ 3 ]D@ ud.
4637693767749000971264812Â ok
\ ...
Dnums[ 198 ]D@ ud.
4075591789781264330331690Â ok
Dnums[ 199 ]D@ ud.
5350353422647252425087405Â ok
=== end test ===
input_rev
Hi,
What about this program. It is written in gforth.
the numbers are in the file "euler13.input" (Anton's file).
I reversed the strings holding the numbers and used a decimal-based adder with carry (digit by digit) (as in primary school) but the summation goes from left to right.
I didn't use foats or double numbers (just strings).
I think it is generalizable for any size (digits or numbers)
\ here, the program begins
s" euler13.input" slurp-file 2constant input
50 constant ns
ns 2 + constant ns+2
100 constant N
20 value ndigits
create input_rev N ns * allot
input_rev N ns * erase
: >input_rev   N 0 do           ns 0 do                  input drop
ns 1- i - j ns+2 * + + c@ input_rev i + ns j
* + c!
          loop
  loop ;
input_rev
create sum ns+2 allot sum ns+2 erase
create sv ns+2 allot sv ns+2 erase
create cry ns+2 allot cry ns+2 erase
create num ns+2 allot num ns+2 erase
: init_sum sum ns+2 erase ;
: init_cry cry ns+2 erase ;
: init_num num ns+2 erase ;
: d>c 48 + ;
: c>d 48 - ;
: >num ( n --) ns * input_rev +Â ns 0 do dup i + c@ c>d num i + c! loop
drop ;
: dda ( r --)
 dup cry + c@ over num + c@ + over sum + c@ + 10 /mod rot swap over 1+ cry + c! sum + c! ;
: (nsad) ns+2 0 do i dda loop ;
: nsad init_sum N 0 do init_num init_cry i >num (nsad) loop ;
: >sv ns+2 0 do i sum + c@ d>c sv ns+2 1 - i - + c! loop ;
: .sum >sv sv ns+2 type ;
: 1st_nz_digit 0 ns+2 0 do sv i + c@ 0 d>c = if 1+ else unloop exit then
loop ;
: .sum_ndigits >sv sv 1st_nz_digit + ndigits type ;
nsad
cr .sum
cr 10 to ndigits .sum_ndigits
cr 20 to ndigits .sum_ndigits
\ here, the end of the program.
the results:
5537376230390876637302048746832985971773659831892672 for the whole sum 5537376230 for 10 digits
55373762303908766373 for 20 digits
Nice. However, it's probably not a practical way to do arithmetic of big >numbers, compared to adding binary representations of the number in
larger chunks than single decimal digits. The machine addition
instructions are suited for 32/64 bit additions. Even my approach using
25 decimal digits at a time is slow because of the need to compute the
carry bits for adding to the high 25 digits. Better to have a contiguous >binary representation of the decimal number across the required memory
size needed to hold the sum.
Krishna Myneni <krishna.myneni@ccreweb.org> writes:
Nice. However, it's probably not a practical way to do arithmetic of big
numbers, compared to adding binary representations of the number in
larger chunks than single decimal digits.
In the Euler 13 case, each input number is used only once, and as I
explained in <2024May3.102927@mips.complang.tuwien.ac.at>, converting
an input number to a binary representation costs more than adding it digit-by-digit (i.e., column by column), which my program from that
posting does.
Here's the full program to solve Euler13 using addition of double
numbers on a 64-bit Forth system using only standard words and no
floating point. With a little work, it can be used to print the full sum
as well.
-- KM
=== begin code ===
\ euler13.4th
\
\ Work out the first ten digits of the sum of the
\ following one-hundred 50-digit numbers.
1 CELLS 8 < ABORT" Needs 64-bit Forth!"
10 constant LF
100 constant N
 50 constant Ndig
create $nums N Ndig * allot
create Dnums[ N 2* 16 * allot
: ]D@ ( a idx -- ud ) 16 * + 2@ ;
: ]D! ( ud a idx -- ) 16 * + 2! ;
: $>ud ( a u -- ud )Â 0 s>d 2swap >number 2drop ;
: $>2ud ( a u -- ud_low ud_high )
  drop Ndig 2/ 2dup + over $>ud 2swap $>ud ;
\ Read N big numbers as strings and then parse into
\ double length array
: read-numbers ( -- )
   N 0 DO
       refill IF
         LF parse dup Ndig <> ABORT" String Length Error!"
         $nums Ndig I * + swap move
       ELSE ABORT
       THEN
   LOOP
   N 0 DO
     $nums Ndig I * + Ndig
     $>2ud Dnums[ I 2* 1+ ]D! Dnums[ I 2* ]D!
   LOOP ;
read-numbers
37107287533902102798797998220837590246510135740250
...
2variable dsum_high
2variable dsum_low
: sumDnums ( -- )
   0 s>d 2dup dsum_high 2! dsum_low 2!
   N 2* 0 DO
     I 1 and IF
       dsum_high 2@ Dnums[ I ]D@ D+ dsum_high 2!
     ELSE
       dsum_low 2@ Dnums[ I ]D@ D+ dsum_low 2!
     THEN
   LOOP ;
sumDnums
\ dsum_low 2@ ud. cr
\ dsum_high 2@ ud. cr
\ add carry portion of low to high for unsigned 25 digit
\ numbers to find the new high portion.
: udsum_25 ( udhigh udlow -- udhigh' )
  10000000000000000000 um/mod nip 1000000 / s>d d+ ;
\ print the leading 10 digits of the sum
: print-leading10 ( -- )
   dsum_high 2@ dsum_low 2@ udsum_25
   100000000000000000 um/mod nip u. ;
print-leading10 cr
=== end code ===
=== run output ===
include euler13
5537376230
 ok
=== end output ===
but there is the somewhat expensive "10 /mod" in DDA, which is
called by the inner loop.
The code works fine but with gforth the execution time of nsad changes to >405ms (instead of 334ms with 10 /mod). So with 10 /mod the code isfaster!
With vfxforth, no change in the execution time between the two versions.
Does this program try to perform the
addition rowwise rather than columnwise?
What about this program. It is written in gforth.adder
the numbers are in the file "euler13.input" (Anton's file).
I reversed the strings holding the numbers and used a decimal-based
with carry (digit by digit) (as in primary school) but the summationgoes
from left to right.
I didn't use floats or double numbers (just strings).
I think it is generalizable for any size (digits or numbers)
This would also have been my approach to solving Euler problem #20 in
Forth:
How many decimal digits are in the number factorial(100)? (648)
minforth@gmx.net (minforth) writes:
This would also have been my approach to solving Euler problem #20 in
Forth:
How many decimal digits are in the number factorial(100)? (648)
Brute force multiplication with 64 bit floats works fine:
: foo 101 1 ?do i s>f f* loop ; ok
1e foo f.s <1> 9.3326215444E157 ok
How many decimal digits are in the number factorial(100)? (648)
The question is:
Find the sum of the digits in the number factorial(100)
and not the number of digits in factorial(100)
1e foo f.s <1> 9.3326215444E157 ok
.. with the minor nuisance that the exponent should be 647
Ahmed wrote:
What about this program. It is written in gforth.adder
the numbers are in the file "euler13.input" (Anton's file).
I reversed the strings holding the numbers and used a decimal-based
with carry (digit by digit) (as in primary school) but the summationgoes
from left to right.
I didn't use floats or double numbers (just strings).
I think it is generalizable for any size (digits or numbers)
This reminds me of BCD coded arithmetic. Sadly, BCD is hardly used
today or is only directly supported by a few CPUs, despite its great >advantages, especially for financial calculations.
D (n,3)CR .ELAPSED ;
albert@spenarnc.xs4all.nl wrote:
minforth <minforth@gmx.net> wrote:
I had toyed with the idea of building a tiny bignum library myself. >>>Binary operations, and with intrinsics, addition/subtraction are also >>>trivial. Multiplication wouldn't be difficult either, for division
the shift-subtract algorithm would be sufficient for me. Let's see,
maybe something for the next rainy season... ;-)
The modulo operation is a real hassle. (We did it for the transputer.)
Out of the blue: IIRC the shift-subtract algo generates quotient AND
modulus as stop criterion.
In article <3729f045786533b7f24c8e4d8f24ecfe@www.novabbs.com>,[..]
minforth <minforth@gmx.net> wrote:
This reminds me of BCD coded arithmetic. Sadly, BCD is hardly used
today or is only directly supported by a few CPUs, despite its great >>advantages, especially for financial calculations.
You mean to imply that DAA DAS AAA AAS AAM AAD instructions are not
available to 32 and/or 64 bits intel/AMD CPU's? To spare a few hundred
of the millions of transistors on the die? At the cost of complaining
by MSDOS emulator builders?
That has to be corroborated, but I think it unlikely.
This reminds me of BCD coded arithmetic. Sadly, BCD is hardly used
today or is only directly supported by a few CPUs, despite its great >advantages, especially for financial calculations.
Some programming
languages
therefore support the numeric type BigDecimal (in addition to BigNum and >sometimes BigFloat, usually via the GMP library), such as Java, JS or
Python.
The sum of the digits of the number 100! = 648
Slightly interesting that the last 24 digits are '0'.
Looking at <https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html>,
this looks like binary fixed point with a decimal scale factor.
Anton Ertl wrote:
Does this program try to perform the
addition rowwise rather than columnwise?
The sum is done as we do it manually with pencil.
the array: sum works as an accumulator.
we add a 50-digit number at once.
You mean to imply that DAA DAS AAA AAS AAM AAD instructions are not
available to 32 and/or 64 bits intel/AMD CPU's? To spare a few hundred
of the millions of transistors on the die? At the cost of complaining
by MSDOS emulator builders?
That has to be corroborated, but I think it unlikely.
Anton Ertl wrote:...
Looking at
<https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html>,
this looks like binary fixed point with a decimal scale factor.
bigdecimal = arbitrary precision math in base 10 (for the mantissa)
The latter to avoid rounding errors like
0.1 + 0.2 -> 0.30000000000000004
I don't know whether above assumed 'binary fixed point with scaling'
could eliminate the rounding errors.
But when I sum multiple numbers by hand, I don't use an accumulator
for whole numbers. I add up all the digits of one column and the
carry from the previous digit colum (which is in the range 0..99 in
the Euler #13 case). In the Euler #13 case this produces a number in
the range 0..999, and then I do the 10 /mod (via # in my program),
with the remainder being the result digit for the column, and the
quotient (in the range 0..99) being the carry for the next column.
melahi_ahmed@yahoo.fr (Ahmed) writes:
Anton Ertl wrote:
Does this program try to perform the
addition rowwise rather than columnwise?
The sum is done as we do it manually with pencil.
the array: sum works as an accumulator.
we add a 50-digit number at once.
But when I sum multiple numbers by hand, I don't use an accumulator
for whole numbers. I add up all the digits of one column and the
carry from the previous digit colum (which is in the range 0..99 in
the Euler #13 case). In the Euler #13 case this produces a number in
the range 0..999, and then I do the 10 /mod (via # in my program),
with the remainder being the result digit for the column, and the
quotient (in the range 0..99) being the carry for the next column.
- anton
minforth@gmx.net (minforth) writes:
Anton Ertl wrote:....
Looking at
<https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html>,
this looks like binary fixed point with a decimal scale factor.
bigdecimal = arbitrary precision math in base 10 (for the mantissa)
What makes you think so?
The latter to avoid rounding errors like
0.1 + 0.2 -> 0.30000000000000004
There is no such rounding error for
1/10 + 2/10 -> 3/10
i.e., fixed point with a scale factor 1/10.
0. DVALUE greatest PRIVATE
: iteration ( dn - dm ) OVER 1 AND IF ( odd) 2DUP D2* D+ 1. D+ 2DUP greatest DMAX TO greatest
ELSE ( even) D2/
ENDIF ; PRIVATE
: sequence ( n -- dk ) \ dk = #terms 1. DLOCAL dk
D BEGIN ( dn -- )iteration ( dm -- ) 1. +TO dk ( dm -- )
2DUP 1. D= UNTIL 2DROP dk ; PRIVATE
0. DVALUE maxchain : Euler14 MS? LOCAL btime
CLEAR maxchain CLEAR greatest
CR ." iter# length elapsed"
CR ." --------------------------"
#1000000 1 DO I sequence ( dk -- )
2DUP maxchain D>
IF ( dk -- )
2DUP TO maxchain
CR I 6 .R 3 SPACES 2DUP D. #16 HTAB MS? btime - 6 .R ." ms "
ENDIF 2DROP LOOP CR ." greatest number encountered = " greatest (n,3) ;
:ABOUT CR ." Try: Euler14 -- Find longest sequence" CR CR ." \ ...37min 53sec till ...39min 30sec = 01min30sec"
CR ." \ PowerBook G4 (867 MHz PowerPC G4)" ;
.ABOUT -euler14 CR
DEPRIVE
Euler 14.
Gauche Scheme
(use gauche.collection) ;; find-max
(define (cltz n) (if (odd? n) (+ 1 (* n 3)) (/ n 2)))
(define (d c n)
(if (= n 1) c (d (+ 1 c) (cltz n))))
(find-max (lrange 1 1000000) :key (pa$ d 1))
===>
837799
On 5/3/2024, mhx wrote:
0. DVALUE greatest PRIVATE
: iteration ( dn - dm ) OVER 1 AND IF ( odd) 2DUP D2* D+ 1. D+ 2DUP greatest DMAX TO greatest
ELSE ( even) D2/
ENDIF ; PRIVATE
: sequence ( n -- dk ) \ dk = #terms 1. DLOCAL dk
D BEGIN ( dn -- )iteration ( dm -- ) 1. +TO dk ( dm -- )
2DUP 1. D= UNTIL 2DROP dk ; PRIVATE
0. DVALUE maxchain : Euler14 MS? LOCAL btime
CLEAR maxchain CLEAR greatest
CR ." iter# length elapsed"
CR ." --------------------------"
#1000000 1 DO I sequence ( dk -- )
2DUP maxchain D>
IF ( dk -- )
2DUP TO maxchain
CR I 6 .R 3 SPACES 2DUP D. #16 HTAB MS? btime - 6 .R ." ms "
ENDIF 2DROP LOOP CR ." greatest number encountered = " greatest (n,3) ;
:ABOUT CR ." Try: Euler14 -- Find longest sequence" CR CR ." \ ...37min 53sec till ...39min 30sec = 01min30sec"
CR ." \ PowerBook G4 (867 MHz PowerPC G4)" ;
.ABOUT -euler14 CR
DEPRIVE
Euler 14.
Gauche Scheme
(use gauche.collection) ;; find-max
(define (cltz n) (if (odd? n) (+ 1 (* n 3)) (/ n 2)))
(define (d c n)
(if (= n 1) c (d (+ 1 c) (cltz n))))
(find-max (lrange 1 1000000) :key (pa$ d 1))
===>
837799
On 5/28/2024, B. Pym wrote:
On 5/3/2024, mhx wrote:
0. DVALUE greatest PRIVATED+
: iteration ( dn - dm ) OVER 1 AND IF ( odd) 2DUP D2* D+ 1.
2DUP greatest DMAX TO greatest
ELSE ( even) D2/
ENDIF ; PRIVATE
: sequence ( n -- dk ) \ dk = #terms 1. DLOCAL dk
D BEGIN ( dn -- )iteration ( dm -- ) 1. +TO dk ( dm -- )
2DUP 1. D= UNTIL 2DROP dk ; PRIVATE
0. DVALUE maxchain : Euler14 MS? LOCAL btime
CLEAR maxchain CLEAR greatest
CR ." iter# length elapsed"
CR ." --------------------------"
#1000000 1 DO I sequence ( dk -- )
2DUP maxchain D>
IF ( dk -- )
2DUP TO maxchain
CR I 6 .R 3 SPACES 2DUP D. #16 HTAB MS? btime - 6 .R ." ms "
ENDIF 2DROP LOOP CR ." greatest number encountered = " >> greatest (n,3) ;
:ABOUT CR ." Try: Euler14 -- Find longest sequence" CR CR ." \ >> ...37min 53sec till ...39min 30sec = 01min30sec"
CR ." \ PowerBook G4 (867 MHz PowerPC G4)" ;
.ABOUT -euler14 CR
DEPRIVE
Euler 14.
Gauche Scheme
(use gauche.collection) ;; find-max
(define (cltz n) (if (odd? n) (+ 1 (* n 3)) (/ n 2)))
(define (d c n)
(if (= n 1) c (d (+ 1 c) (cltz n))))
(find-max (lrange 1 1000000) :key (pa$ d 1))
===>
837799
Ruby:
def cltz n
n.odd? ? n*3+1 : n/2
end
def d n,c=1
1==n ? c : d(cltz(n), c+1)
end
(1..999_999).max_by{|i| d i}
===>
837799
On 5/28/2024, B. Pym wrote:
On 5/3/2024, mhx wrote:
0. DVALUE greatest PRIVATED+
: iteration ( dn - dm ) OVER 1 AND IF ( odd) 2DUP D2* D+ 1.
2DUP greatest DMAX TO greatest
ELSE ( even) D2/
ENDIF ; PRIVATE
: sequence ( n -- dk ) \ dk = #terms 1. DLOCAL dk
D BEGIN ( dn -- )iteration ( dm -- ) 1. +TO dk ( dm -- )
2DUP 1. D= UNTIL 2DROP dk ; PRIVATE
0. DVALUE maxchain : Euler14 MS? LOCAL btime
CLEAR maxchain CLEAR greatest
CR ." iter# length elapsed"
CR ." --------------------------"
#1000000 1 DO I sequence ( dk -- )
2DUP maxchain D>
IF ( dk -- )
2DUP TO maxchain
CR I 6 .R 3 SPACES 2DUP D. #16 HTAB MS? btime - 6 .R ." ms "
ENDIF 2DROP LOOP CR ." greatest number encountered = " >> greatest (n,3) ;
:ABOUT CR ." Try: Euler14 -- Find longest sequence" CR CR ." \ >> ...37min 53sec till ...39min 30sec = 01min30sec"
CR ." \ PowerBook G4 (867 MHz PowerPC G4)" ;
.ABOUT -euler14 CR
DEPRIVE
Euler 14.
Gauche Scheme
(use gauche.collection) ;; find-max
(define (cltz n) (if (odd? n) (+ 1 (* n 3)) (/ n 2)))
(define (d c n)
(if (= n 1) c (d (+ 1 c) (cltz n))))
(find-max (lrange 1 1000000) :key (pa$ d 1))
===>
837799
Ruby:
def cltz n
n.odd? ? n*3+1 : n/2
end
def d n,c=1
1==n ? c : d(cltz(n), c+1)
end
(1..999_999).max_by{|i| d i}
===>
837799
Shorter:
d = ->n,c{1==n ? c : d[n.odd? ? n*3+1 : n/2, c+1]}
(1..99).max_by{|i| d[i,1]}
On 5/28/2024, B. Pym wrote:
On 5/3/2024, mhx wrote:
0. DVALUE greatest PRIVATE
: iteration ( dn - dm ) OVER 1 AND IF ( odd) 2DUP D2* D+ 1. D+ 2DUP greatest DMAX TO greatest
ELSE ( even) D2/
ENDIF ; PRIVATE
: sequence ( n -- dk ) \ dk = #terms 1. DLOCAL dk
D BEGIN ( dn -- )iteration ( dm -- ) 1. +TO dk ( dm -- )
2DUP 1. D= UNTIL 2DROP dk ; PRIVATE
0. DVALUE maxchain : Euler14 MS? LOCAL btime
CLEAR maxchain CLEAR greatest
CR ." iter# length elapsed"
CR ." --------------------------"
#1000000 1 DO I sequence ( dk -- )
2DUP maxchain D>
IF ( dk -- )
2DUP TO maxchain
CR I 6 .R 3 SPACES 2DUP D. #16 HTAB MS? btime - 6 .R ." ms "
ENDIF 2DROP LOOP CR ." greatest number encountered = " greatest (n,3) ;
:ABOUT CR ." Try: Euler14 -- Find longest sequence" CR CR ." \ ...37min 53sec till ...39min 30sec = 01min30sec"
CR ." \ PowerBook G4 (867 MHz PowerPC G4)" ;
.ABOUT -euler14 CR
DEPRIVE
Euler 14.
Gauche Scheme
(use gauche.collection) ;; find-max
(define (cltz n) (if (odd? n) (+ 1 (* n 3)) (/ n 2)))
(define (d c n)
(if (= n 1) c (d (+ 1 c) (cltz n))))
(find-max (lrange 1 1000000) :key (pa$ d 1))
===>
837799
Ruby:
def cltz n
n.odd? ? n*3+1 : n/2
end
def d n,c=1
1==n ? c : d(cltz(n), c+1)
end
(1..999_999).max_by{|i| d i}
===>
837799
Another one (with quotations!!)
1000000 1 :noname 0 0 2swap do i dup 1 [: over 1 <> if swap dup 1 and
if
3 * 1+ else 2/ then swap recurse 1+ else nip then ;] execute >r over
r@
< if -rot 2drop r> else drop rdrop then loop drop ; execute .
B. Pym wrote:
On 5/28/2024, B. Pym wrote:
On 5/3/2024, mhx wrote:
0. DVALUE greatest PRIVATED+
: iteration ( dn - dm ) OVER 1 AND IF ( odd) 2DUP D2* D+ 1.
2DUP greatest DMAX TO greatest
ELSE ( even) D2/
ENDIF ; PRIVATE
: sequence ( n -- dk ) \ dk = #terms 1. DLOCAL dk
S>D BEGIN ( dn -- )
iteration ( dm -- ) 1. +TO dk ( dm -- )
2DUP 1. D= UNTIL 2DROP dk ; PRIVATE
0. DVALUE maxchain : Euler14 MS? LOCAL btime
CLEAR maxchain CLEAR greatest
CR ." iter# length elapsed"
CR ." --------------------------"
#1000000 1 DO I sequence ( dk -- )
2DUP maxchain D>
IF ( dk -- )
2DUP TO maxchain
CR I 6 .R 3 SPACES 2DUP D. #16 HTAB MS? btime - 6 .R ." ms "
ENDIF 2DROP LOOP CR ." greatest number encountered = " >>> greatest (n,3) ;
:ABOUT CR ." Try: Euler14 -- Find longest sequence" CR CR ." \ >>> ...37min 53sec till ...39min 30sec = 01min30sec"
CR ." \ PowerBook G4 (867 MHz PowerPC G4)" ;
.ABOUT -euler14 CR
DEPRIVE
Euler 14.
Gauche Scheme
(use gauche.collection) ;; find-max
(define (cltz n) (if (odd? n) (+ 1 (* n 3)) (/ n 2)))
(define (d c n)
(if (= n 1) c (d (+ 1 c) (cltz n))))
(find-max (lrange 1 1000000) :key (pa$ d 1))
===>
837799
Ruby:
def cltz n
n.odd? ? n*3+1 : n/2
end
def d n,c=1
1==n ? c : d(cltz(n), c+1)
end
(1..999_999).max_by{|i| d i}
===>
837799
Hi,
With gforth:
: cltz ( n -- n) dup 1 and if 3 * 1+ else 2/ then ;
: d ( n c -- c) over 1 <> if swap cltz swap recurse 1+ else nip then ;
: cmp dup 1 d >r over r@ < if -rot 2drop r> else drop rdrop then ;
: do-it 0 0 2swap do i cmp loop drop ;
1000000 1 do-it . 837799 ok
Bye--
If you are going to promote your favorite language among
Forth enthousiast, the least you can do is explaining the
program and the advantage over Forth.
On 5/28/2024, B. Pym wrote:
On 5/3/2024, mhx wrote:
0. DVALUE greatest PRIVATE
: iteration ( dn - dm ) OVER 1 AND IF ( odd) 2DUP D2* D+ 1. D+ 2DUP greatest DMAX TO greatest
ELSE ( even) D2/
ENDIF ; PRIVATE
: sequence ( n -- dk ) \ dk = #terms 1. DLOCAL dk
S>D BEGIN ( dn -- )
iteration ( dm -- ) 1. +TO dk ( dm -- )
2DUP 1. D= UNTIL 2DROP dk ; PRIVATE
0. DVALUE maxchain : Euler14 MS? LOCAL btime
CLEAR maxchain CLEAR greatest
CR ." iter# length elapsed"
CR ." --------------------------"
#1000000 1 DO I sequence ( dk -- )
2DUP maxchain D>
IF ( dk -- )
2DUP TO maxchain
CR I 6 .R 3 SPACES 2DUP D. #16 HTAB MS? btime - 6 .R ." ms "
ENDIF 2DROP LOOP CR ." greatest number encountered = " greatest (n,3) ;
:ABOUT CR ." Try: Euler14 -- Find longest sequence" CR CR ." \ ...37min 53sec till ...39min 30sec = 01min30sec"
CR ." \ PowerBook G4 (867 MHz PowerPC G4)" ;
.ABOUT -euler14 CR
DEPRIVE
Euler 14.
Gauche Scheme
(use gauche.collection) ;; find-max
(define (cltz n) (if (odd? n) (+ 1 (* n 3)) (/ n 2)))
(define (d c n)
(if (= n 1) c (d (+ 1 c) (cltz n))))
(find-max (lrange 1 1000000) :key (pa$ d 1))
===>
837799
Ruby:
def cltz n
n.odd? ? n*3+1 : n/2
end
def d n,c=1
1==n ? c : d(cltz(n), c+1)
end
(1..999_999).max_by{|i| d i}
837799
albert@spenarnc.xs4all.nl writes:
If you are going to promote your favorite language among
Forth enthousiast, the least you can do is explaining the
program and the advantage over Forth.
I'd like to see more such comparisons, but maybe there is a better group
to celebrate Project-Euler, Rosetta-Code and similar "hobbies"?
albert@spenarnc.xs4all.nl writes:
Bragging about how good you program is, is to be done in projecteuler
itself.
Why so negative?
Did I brag? I do not think so. I just want to see languages compared,
be it with or without eulerisms...
Bragging about how good you program is, is to be done in projecteuler
itself.
My solution in ciforth (indirect threaded) takes 0.7 seconds
AMD 4 Ghz).
My solution in ciforth (indirect threaded) takes 0.7 seconds
AMD 4 Ghz).
Paul Rubin wrote:
[..]
Wait what, I think I have #13 as the wrong problem? Yes, I had a saved euler13.fs file that I posted, but it was actually for problem 14. Not sure how that happened, sorry.
Look Mum, no recursion.
(*
* LANGUAGE : ANS Forth with extensions
* PROJECT : Forth Environments
* DESCRIPTION : Collection at http://projecteuler.net/index.php?section=problems
* CATEGORY : Contests * AUTHOR : Marcel Hendrix * LAST CHANGE : April 21, 2008, Marcel Hendrix *)
NEEDS -miscutil
REVISION -euler14 "--- Longest sequence Version 1.00 ---"
PRIVATES
DOC
(*
The following iterative sequence is defined for the set of positive integers:
n -> n/2 (n is even)
n -> 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1
It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is
thought that all starting numbers finish at 1.
Which starting number, under one million, produces the longest chain?
NOTE: Once the chain starts the terms are allowed to go above one million.
*)
ENDDOC
0. DVALUE greatest PRIVATE
: iteration ( dn - dm ) OVER 1 AND IF ( odd) 2DUP D2* D+ 1. D+ 2DUP greatest DMAX TO greatest
ELSE ( even) D2/
ENDIF ; PRIVATE
: sequence ( n -- dk ) \ dk = #terms 1. DLOCAL dk
D BEGIN ( dn -- )iteration ( dm -- ) 1. +TO dk ( dm -- )
2DUP 1. D= UNTIL 2DROP dk ; PRIVATE
0. DVALUE maxchain : Euler14 MS? LOCAL btime
CLEAR maxchain CLEAR greatest
CR ." iter# length elapsed"
CR ." --------------------------"
#1000000 1 DO I sequence ( dk -- )
2DUP maxchain D>
IF ( dk -- )
2DUP TO maxchain
CR I 6 .R 3 SPACES 2DUP D. #16 HTAB MS? btime - 6 .R ." ms "
ENDIF 2DROP LOOP CR ." greatest number encountered = " greatest (n,3) ;
:ABOUT CR ." Try: Euler14 -- Find longest sequence" CR CR ." \ ...37min 53sec till ...39min 30sec = 01min30sec"
CR ." \ PowerBook G4 (867 MHz PowerPC G4)" ;
.ABOUT -euler14 CR
DEPRIVE
(* End of Source *)
Why did you chose floats here?
minforth@gmx.net (minforth) writes:
Why did you chose floats here?
I think because using 32-bit ints would have encountered overflow,
for example at n=159487.
On 5/3/2024, mhx wrote:
Paul Rubin wrote:
[..]
Wait what, I think I have #13 as the wrong problem? Yes, I had a saved euler13.fs file that I posted, but it was actually for problem 14. Not sure how that happened, sorry.
Look Mum, no recursion.
(*
* LANGUAGE : ANS Forth with extensions
* PROJECT : Forth Environments
* DESCRIPTION : Collection at http://projecteuler.net/index.php?section=problems
* CATEGORY : Contests * AUTHOR : Marcel Hendrix * LAST CHANGE : April 21, 2008, Marcel Hendrix *)
NEEDS -miscutil
REVISION -euler14 "--- Longest sequence Version 1.00 ---"
PRIVATES
DOC
(*
The following iterative sequence is defined for the set of positive integers:
n -> n/2 (n is even)
n -> 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1
It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is
thought that all starting numbers finish at 1.
Which starting number, under one million, produces the longest chain?
NOTE: Once the chain starts the terms are allowed to go above one million.
*)
ENDDOC
0. DVALUE greatest PRIVATE
: iteration ( dn - dm ) OVER 1 AND IF ( odd) 2DUP D2* D+ 1. D+ 2DUP greatest DMAX TO greatest
ELSE ( even) D2/
ENDIF ; PRIVATE
: sequence ( n -- dk ) \ dk = #terms 1. DLOCAL dk
D BEGIN ( dn -- )iteration ( dm -- ) 1. +TO dk ( dm -- )
2DUP 1. D= UNTIL 2DROP dk ; PRIVATE
0. DVALUE maxchain : Euler14 MS? LOCAL btime
CLEAR maxchain CLEAR greatest
CR ." iter# length elapsed"
CR ." --------------------------"
#1000000 1 DO I sequence ( dk -- )
2DUP maxchain D>
IF ( dk -- )
2DUP TO maxchain
CR I 6 .R 3 SPACES 2DUP D. #16 HTAB MS? btime - 6 .R ." ms "
ENDIF 2DROP LOOP CR ." greatest number encountered = " greatest (n,3) ;
:ABOUT CR ." Try: Euler14 -- Find longest sequence" CR CR ." \ ...37min 53sec till ...39min 30sec = 01min30sec"
CR ." \ PowerBook G4 (867 MHz PowerPC G4)" ;
.ABOUT -euler14 CR
DEPRIVE
(* End of Source *)
;; GForth (32-bit)
: fodd? f>d drop 1 and ;
: cltz fdup fodd?
if 3e f* 1e f+ else 2e f/ then ;
: step ( F: n cnt -- F: n2 cnt2) 1+ cltz ;
: chain ( F: n cnt -- F: 1e cnt2)
1e fover f<
if step recurse then ;
: keep-best { n cnt cnt2 m }
fdrop cnt cnt2 <
if m cnt2 else n cnt then ;
: foo cr
0 0
1000000 1 do
i s>f 1 chain ( n cnt cnt2 )
i keep-best
loop . . cr ;
utime foo utime 2swap d- 1000 um/mod . ." milliseconds" drop
===>
525 837799
10606 milliseconds
On 5/3/2024, mhx wrote:
Paul Rubin wrote:
[..]
Wait what, I think I have #13 as the wrong problem? Yes, I had a saved euler13.fs file that I posted, but it was actually for problem 14. Not sure how that happened, sorry.
Look Mum, no recursion.
(*
* LANGUAGE : ANS Forth with extensions
* PROJECT : Forth Environments
* DESCRIPTION : Collection at http://projecteuler.net/index.php?section=problems
* CATEGORY : Contests * AUTHOR : Marcel Hendrix * LAST CHANGE : April 21, 2008, Marcel Hendrix *)
NEEDS -miscutil
REVISION -euler14 "--- Longest sequence Version 1.00 ---"
PRIVATES
DOC
(*
The following iterative sequence is defined for the set of positive integers:
n -> n/2 (n is even)
n -> 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1
It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is
thought that all starting numbers finish at 1.
Which starting number, under one million, produces the longest chain?
NOTE: Once the chain starts the terms are allowed to go above one million.
*)
ENDDOC
0. DVALUE greatest PRIVATE
: iteration ( dn - dm ) OVER 1 AND IF ( odd) 2DUP D2* D+ 1. D+ 2DUP greatest DMAX TO greatest
ELSE ( even) D2/
ENDIF ; PRIVATE
: sequence ( n -- dk ) \ dk = #terms 1. DLOCAL dk
D BEGIN ( dn -- )iteration ( dm -- ) 1. +TO dk ( dm -- )
2DUP 1. D= UNTIL 2DROP dk ; PRIVATE
0. DVALUE maxchain : Euler14 MS? LOCAL btime
CLEAR maxchain CLEAR greatest
CR ." iter# length elapsed"
CR ." --------------------------"
#1000000 1 DO I sequence ( dk -- )
2DUP maxchain D>
IF ( dk -- )
2DUP TO maxchain
CR I 6 .R 3 SPACES 2DUP D. #16 HTAB MS? btime - 6 .R ." ms "
ENDIF 2DROP LOOP CR ." greatest number encountered = " greatest (n,3) ;
:ABOUT CR ." Try: Euler14 -- Find longest sequence" CR CR ." \ ...37min 53sec till ...39min 30sec = 01min30sec"
CR ." \ PowerBook G4 (867 MHz PowerPC G4)" ;
.ABOUT -euler14 CR
DEPRIVE
(* End of Source *)
;; GForth (32-bit)
: fodd? f>d drop 1 and ;
: cltz fdup fodd?
if 3e f* 1e f+ else 2e f/ then ;
: step ( F: n cnt -- F: n2 cnt2) 1+ cltz ;
: chain ( F: n cnt -- F: 1e cnt2)
1e fover f<
if step recurse then ;
: keep-best { n cnt cnt2 m }
fdrop cnt cnt2 <
if m cnt2 else n cnt then ;
: foo cr
0 0
1000000 1 do
i s>f 1 chain ( n cnt cnt2 )
i keep-best
loop . . cr ;
utime foo utime 2swap d- 1000 um/mod . ." milliseconds" drop
===>
525 837799
10606 milliseconds
I probably would have used double numbers to avoid type
conversions, and because not all Forth systems have floats.
The program euler13.mf:
\ Work out the first ten digits of the sum of the
\ following one-hundred 50-digit numbers.
On 5/1/2024, minforth wrote:
The program euler13.mf:
\ Work out the first ten digits of the sum of the
\ following one-hundred 50-digit numbers.
SP-Forth
REQUIRE S>NUM ~nn\lib\s2num.f
REQUIRE N>S ~nn\lib\num2s.f
REQUIRE F. lib/include/float2.f
16 SET-PRECISION
REQUIRE CASE-INS lib/ext/caseins.f
: eu13
0e
100 0 do
refill drop 10 parse 13 min s>double d>f f+
loop
f>d double>s 10 min type ;
eu13
37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 74324986199524741059474233309513058123726617309629 91942213363574161572522430563301811072406154908250 23067588207539346171171980310421047513778063246676 89261670696623633820136378418383684178734361726757 28112879812849979408065481931592621691275889832738 44274228917432520321923589422876796487670272189318 47451445736001306439091167216856844588711603153276 70386486105843025439939619828917593665686757934951 62176457141856560629502157223196586755079324193331 64906352462741904929101432445813822663347944758178 92575867718337217661963751590579239728245598838407 58203565325359399008402633568948830189458628227828 80181199384826282014278194139940567587151170094390 35398664372827112653829987240784473053190104293586 86515506006295864861532075273371959191420517255829 71693888707715466499115593487603532921714970056938 54370070576826684624621495650076471787294438377604 53282654108756828443191190634694037855217779295145 36123272525000296071075082563815656710885258350721 45876576172410976447339110607218265236877223636045 17423706905851860660448207621209813287860733969412 81142660418086830619328460811191061556940512689692 51934325451728388641918047049293215058642563049483 62467221648435076201727918039944693004732956340691 15732444386908125794514089057706229429197107928209 55037687525678773091862540744969844508330393682126 18336384825330154686196124348767681297534375946515 80386287592878490201521685554828717201219257766954 78182833757993103614740356856449095527097864797581 16726320100436897842553539920931837441497806860984 48403098129077791799088218795327364475675590848030 87086987551392711854517078544161852424320693150332 59959406895756536782107074926966537676326235447210 69793950679652694742597709739166693763042633987085 41052684708299085211399427365734116182760315001271 65378607361501080857009149939512557028198746004375 35829035317434717326932123578154982629742552737307 94953759765105305946966067683156574377167401875275 88902802571733229619176668713819931811048770190271 25267680276078003013678680992525463401061632866526 36270218540497705585629946580636237993140746255962 24074486908231174977792365466257246923322810917141 91430288197103288597806669760892938638285025333403 34413065578016127815921815005561868836468420090470 23053081172816430487623791969842487255036638784583 11487696932154902810424020138335124462181441773470 63783299490636259666498587618221225225512486764533 67720186971698544312419572409913959008952310058822 95548255300263520781532296796249481641953868218774 76085327132285723110424803456124867697064507995236 37774242535411291684276865538926205024910326572967 23701913275725675285653248258265463092207058596522 29798860272258331913126375147341994889534765745501 18495701454879288984856827726077713721403798879715 38298203783031473527721580348144513491373226651381 34829543829199918180278916522431027392251122869539 40957953066405232632538044100059654939159879593635 29746152185502371307642255121183693803580388584903 41698116222072977186158236678424689157993532961922 62467957194401269043877107275048102390895523597457 23189706772547915061505504953922979530901129967519 86188088225875314529584099251203829009407770775672 11306739708304724483816533873502340845647058077308 82959174767140363198008187129011875491310547126581 97623331044818386269515456334926366572897563400500 42846280183517070527831839425882145521227251250327 55121603546981200581762165212827652751691296897789 32238195734329339946437501907836945765883352399886 75506164965184775180738168837861091527357929701337 62177842752192623401942399639168044983993173312731 32924185707147349566916674687634660915035914677504 99518671430235219628894890102423325116913619626622 73267460800591547471830798392868535206946944540724 76841822524674417161514036427982273348055556214818 97142617910342598647204516893989422179826088076852 87783646182799346313767754307809363333018982642090 10848802521674670883215120185883543223812876952786 71329612474782464538636993009049310363619763878039 62184073572399794223406235393808339651327408011116 66627891981488087797941876876144230030984490851411 60661826293682836764744779239180335110989069790714 85786944089552990653640447425576083659976645795096 66024396409905389607120198219976047599490197230297 64913982680032973156037120041377903785566085089252 16730939319872750275468906903707539413042652315011 94809377245048795150954100921645863754710598436791 78639167021187492431995700641917969777599028300699 15368713711936614952811305876380278410754449733078 40789923115535562561142322423255033685442488917353 44889911501440648020369068063960672322193204149535 41503128880339536053299340368006977710650566631954 81234880673210146739058568557934581403627822703280 82616570773948327592232845941706525094512325230608 22918802058777319719839450180888072429661980811197 77158542502016545090413245809786882778948721859617 72107838435069186155435662884062257473692284509516 20849603980134001723930671666823555245252804609722 53503534226472524250874054075591789781264330331690
5537376230
One of the
constraints of the Euler problems was to use less than 1 minute of
computer time, but the project started in 2001, which means computers
100x(?) slower than modern ones.
minforth@gmx.net (minforth) writes:
I probably would have used double numbers to avoid type
conversions, and because not all Forth systems have floats.
They also don't all have 32-bit cells :P. Doubles are also a big
nuisance to use.
I think a proper solution to this problem involves memoization or maybe
some mathematical trick that I haven't figured out. One of the
constraints of the Euler problems was to use less than 1 minute of
computer time, but the project started in 2001, which means computers
100x(?) slower than modern ones. So a good solution on a modern machine >should take less than 1 second, and plain brute force is considerably
slower.
s" euler13.input" slurp-file 2constant input
: sumcolumn ( ucarry1 c-addr -- ucarry2 )
5100 bounds ?do
i c@ +
51 +loop
'0' 100 * - 0 # drop ;
: sum ( -- c-addr2 u2 )
0 <<#
input drop 50 1 mem-do
i sumcolumn
loop
0 #s #> ;
sum drop 10 type cr
This outputs "5537376230".
project started in 2001, which means computers 100x(?) slower than
modern ones.
Athlon MP 1800+ 1533MHz, 256KB L2, AMD760MP, Debian Etch 1.412
Xeon W-1370P (=Core i7-11700K), 5200MHz, Debian 11 (64-bit) 0.175
anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
project started in 2001, which means computers 100x(?) slower than >>>modern ones.
Athlon MP 1800+ 1533MHz, 256KB L2, AMD760MP, Debian Etch 1.412
Xeon W-1370P (=Core i7-11700K), 5200MHz, Debian 11 (64-bit) 0.175
Hmm, pretty good, stuff in 2001 was faster than I remembered. But that
was a state of the art machine. I think I was mostly using a 600 mhz
Pentium III at the time. I might not have even gotten that though.
Before that, I had a 233 MHz Pentium MMX.
I had actually thought of the Euler project as going back further, like
to the 386 era if not before.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 504 |
Nodes: | 16 (2 / 14) |
Uptime: | 25:06:53 |
Calls: | 9,907 |
Calls today: | 3 |
Files: | 13,799 |
Messages: | 6,345,634 |