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
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
281
Nodes:
10 (0
/
10)
Uptime:
14:57:27
Calls:
2,401
Files:
5,155
D/L today:
29 files
(10,006K bytes)
Messages:
435,949
Synchronet Oneliners
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 ?
Witness@rdbbs Sun Oct 26 00:03:42 2025 Is this the BBS yet?