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
Doc
Sun May 5 19:05:50 2024
from
Manitoba
via
Telnet
Vintagegeek
Sun May 5 18:39:31 2024
from
Swarthmore, Pa
via
Telnet
Guest
Sun May 5 17:21:30 2024
from
Nj
via
Telnet
Vintagegeek
Sun May 5 13:33:53 2024
from
Swarthmore, Pa
via
Telnet
System Info
Sysop:
deepend
Location:
Calgary, Alberta
Users:
241
Nodes:
10 (0
/
10)
Uptime:
39:15:19
Calls:
1,469
Calls today:
5
Files:
3,376
Messages:
358,998
Synchronet Oneliners
Vintagegeek@rdbbs Fri Apr 26 05:27:11 2024 Running out of energy. Coffee Time
Vintagegeek@rdbbs Sun Apr 28 05:40:04 2024 go giants
Vintagegeek@rdbbs Sun Apr 28 13:42:10 2024 Go Phillies
Vintagegeek@rdbbs Mon Apr 29 04:53:15 2024 Go Canucks
Vintagegeek@rdbbs Wed May 1 05:32:11 2024 Oh God Its already May
Doc@rdbbs Sun May 5 19:05:31 2024 Hey everyone! Good to be here