just for fun: calculating primes only using unary numbers
From yeti@yeti@tilde.institute to tilde.institute on Sun Feb 11 01:39:52 2024
I somewhen had to do it!
------------------------------------------------------------------------
$ cat unary_prime_generator.sh
#!/bin/sh -e
##
## 20240211/yeti:
## using only unary numbers (lots of fngers) to calculate primes.
##
dec() { echo ${#1} ; }
a=11
while test x$l != x111111111111111111111111111111111111111111
do
eval c=\$X$a
if test -z "$c"
then
c=$a
l=1$l
echo "prime $l ($(dec $l)) is $c ($(dec $c))"
fi
d=$a$c
while test -n "$(eval t=\$X$d ; echo $t)"
do
d=$d$c
done
eval X$d=\$c
a=1$a
done
$ ./unary_prime_generator.sh | head -12
prime 1 (1) is 11 (2)
prime 11 (2) is 111 (3)
prime 111 (3) is 11111 (5)
prime 1111 (4) is 1111111 (7)
prime 11111 (5) is 11111111111 (11)
prime 111111 (6) is 1111111111111 (13)
prime 1111111 (7) is 11111111111111111 (17)
prime 11111111 (8) is 1111111111111111111 (19)
prime 111111111 (9) is 11111111111111111111111 (23)
prime 1111111111 (10) is 11111111111111111111111111111 (29)
prime 11111111111 (11) is 1111111111111111111111111111111 (31)
prime 111111111111 (12) is 1111111111111111111111111111111111111 (37)
$ _
------------------------------------------------------------------------
--
I do not bite, I just want to play.
--- Synchronet 3.19a-Linux NewsLink 1.113
From yeti@yeti@tilde.institute to tilde.institute on Sun Feb 11 01:48:28 2024
I somewhen had to do it!
------------------------------------------------------------------------
$ cat unary_prime_generator.sh
#!/bin/sh -e
##
## 20240211/yeti:
## using only unary numbers (lots of fingers) to calculate primes.
##
dec() { echo ${#1} ; }
a=11
while test x$l != x111111111111111111111111111111111111111111
do
eval c=\$X$a
if test -z "$c"
then
c=$a
l=1$l
echo "prime $l ($(dec $l)) is $c ($(dec $c))"
fi
d=$a$c
while test -n "$(eval t=\$X$d ; echo $t)"
do
d=$d$c
done
eval X$d=\$c
a=1$a
done
$ ./unary_prime_generator.sh | head -12
prime 1 (1) is 11 (2)
prime 11 (2) is 111 (3)
prime 111 (3) is 11111 (5)
prime 1111 (4) is 1111111 (7)
prime 11111 (5) is 11111111111 (11)
prime 111111 (6) is 1111111111111 (13)
prime 1111111 (7) is 11111111111111111 (17)
prime 11111111 (8) is 1111111111111111111 (19)
prime 111111111 (9) is 11111111111111111111111 (23)
prime 1111111111 (10) is 11111111111111111111111111111 (29)
prime 11111111111 (11) is 1111111111111111111111111111111 (31)
prime 111111111111 (12) is 1111111111111111111111111111111111111 (37)
$ _
------------------------------------------------------------------------
--
I do not bite, I just want to play.
--- Synchronet 3.19a-Linux NewsLink 1.113
Who's Online
Recent Visitors
Deepend
Mon May 25 15:48:21 2026
from
Calgary, Ab
via
HTTPS
Darknetgirl
Mon May 25 04:31:27 2026
from
London
via
Telnet
Lord Jord
Sat May 23 15:08:49 2026
from
Olds, Alberta
via
Telnet
H333d
Sat May 23 11:59:31 2026
from
Olds, Alberta
via
HTTPS
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
312
Nodes:
10 (0
/
10)
Uptime:
00:14:42
Calls:
2,557
Calls today:
1
Files:
6,003
D/L today:
54 files
(20,717K bytes)
Messages:
473,789
Synchronet Oneliners
Duke@rdbbs Sat May 16 10:42:25 2026 Duke is Here
Duke@rdbbs Sun May 17 09:24:34 2026 Fixer Upper - Chip and Jojo
H333d@rdbbs Sun May 17 13:40:12 2026 im feeling #green today
Vintagegeek@rdbbs Mon May 18 11:28:35 2026 Green It Is
Underlord@rdbbs Tue May 19 00:36:34 2026 just set up win3.1 on my retro system, feels like childhood
Lord Jord@rdbbs Sat May 23 15:08:21 2026 hello from olds!!