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
Sun Sep 7 11:01:26 2025
from
Swarthmore, Pa
via
Telnet
Dextile
Sun Sep 7 08:31:53 2025
from
Calgary, Ab
via
Telnet
Vintagegeek
Sun Sep 7 05:11:25 2025
from
Swarthmore, Pa
via
Telnet
Darknetgirl
Sat Sep 6 12:08:09 2025
from
London
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
278
Nodes:
10 (0
/
10)
Uptime:
15:12:15
Calls:
2,357
Calls today:
3
Files:
4,990
D/L today:
218 files
(61,623K bytes)
Messages:
428,728
Synchronet Oneliners
Vintagegeek@rdbbs Tue Aug 12 07:14:02 2025 Cass
Vintagegeek@rdbbs Fri Aug 22 05:53:33 2025 OpenWide
Serpentchain@rdbbs Tue Sep 2 20:21:16 2025 Glowing Apple Hums,
Serpentchain@rdbbs Tue Sep 2 20:21:26 2025 Telnet Whispers Through The Night,
Serpentchain@rdbbs Tue Sep 2 20:21:35 2025 BBS Dreams In Code.
Vintagegeek@rdbbs Wed Sep 3 11:26:08 2025 Heading to Banf f f