Code:
ubu@raspberrypi:~ $ sudo apt install rakuReading package lists... DoneBuilding dependency tree... DoneReading state information... Doneraku is already the newest version (6.d.7).0 upgraded, 0 newly installed, 0 to remove and 138 not upgraded.ubu@raspberrypi:~ $ nano apn.rakuubu@raspberrypi:~ $ ubu@raspberrypi:~ $ raku apn.rakux: 100, n: 14, x/n: 7.142857x: 1000, n: 89, x/n: 11.235955x: 10000, n: 590, x/n: 16.949153x: 100000, n: 3883, x/n: 25.753284x: 1000000, n: 30123, x/n: 33.197225^Z[2]+ Stopped raku apn.rakuubu@raspberrypi:~ $ neofetch --offubu@raspberrypi---------------OS: Debian GNU/Linux 12 (bookworm) aarch64Host: Raspberry Pi 4 Model B Rev 1.4Kernel: 6.6.51+rpt-rpi-v8Uptime: 4 days, 22 hours, 27 minsPackages: 2794 (dpkg)Shell: bash 5.2.15Terminal: /dev/pts/8CPU: (4) @ 1.800GHzMemory: 1226MiB / 7808MiBubu@raspberrypi:~ $ dateSun 17 Nov 13:19:56 GMT 2024ubu@raspberrypi:~ $
Additive Primes are a fascinating subset of prime numbers where the sum of their digits, xxx, is also a prime number. For example, the prime number 23 has the digit sum 2+3=52 + 3 = 52+3=5, which is also prime, making 23 an Additive Prime. This property offers an additional layer of structure within the vast domain of prime numbers, blending arithmetic properties with digit-based patterns.
Raku code on Debian GNU/Linux 12 (bookworm) aarch64
----------------------------------------------------------------------
sub is-additive-prime(Int $n) {
return False unless $n.is-prime; # Check if the number is prime
my $sum = [+] $n.comb.map(*.Int); # Sum of digits
return $sum.is-prime; # Check if the digit sum is prime
}
sub additive-primes-count(Int $x) {
(1..$x).grep(&is-additive-prime).elems; # Count Additive Primes in range
}
my $x = 100;
while $x <= 10000000000 {
my $n = additive-primes-count($x);
my $ratio = $x / $n;
say "x: $x, n: $n, x/n: $ratio";
$x *= 10;
}
Statistics: Posted by geev03 — Sun Nov 17, 2024 1:23 pm