added more examples, project euler

This commit is contained in:
2025-09-15 18:54:31 +01:00
parent 66d257bf83
commit 3f0d61f466
5 changed files with 79 additions and 9 deletions

38
examples/euler-3.zorth Normal file
View File

@@ -0,0 +1,38 @@
: over swap dup rot rot ;
: rem over over / * - ;
: false 0 ;
: true 1 ;
: palindrome?
mem 0 !
dup begin
dup 0 >
while
dup 10 rem mem @ 10 * + mem swap !
10 /
repeat
drop
mem @ =
;
: ans mem 8 + ;
1 begin
dup 999 <
while
1 begin
dup 999 <
while
over over *
dup palindrome? if
dup ans @ > if ans swap ! else drop fi
else
drop
fi
1+
repeat
drop
1+
repeat
ans @ .