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
Vintagegeek
Mon Oct 13 18:21:14 2025
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Sun Oct 12 08:38:03 2025
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Fri Oct 10 11:48:05 2025
from
Swarthmore, Pa
via
Telnet
Vintagegeek
Wed Oct 8 11:36:28 2025
from
Swarthmore, Pa
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
279
Nodes:
10 (0
/
10)
Uptime:
62:01:23
Calls:
2,392
Files:
5,123
D/L today:
50 files
(18,689K bytes)
Messages:
434,715
Synchronet Oneliners
Vintagegeek@rdbbs Thu Sep 25 09:47:55 2025 The Price is Right
Vintagegeek@rdbbs Thu Oct 2 09:15:49 2025 Next
Vintagegeek@rdbbs Fri Oct 3 10:18:45 2025 Gotta gotra gotta - make a hole
Dev00903@rdbbs Mon Oct 6 04:48:23 2025 hello guys
Dev00903@rdbbs Mon Oct 6 04:48:48 2025 how it works this?
Vintagegeek@rdbbs Fri Oct 10 11:47:51 2025 Is it 1984 ?