Factor2

From CleanPosts

Jump to: navigation, search

List primes between 2 and any number

#!/bin/bash
for (( i=2; i<=$1; i++ ));do
l=$(factor $i | cut -d : -f 1)
r=$(factor $i | cut -d : -f 2 | sed 's/ //g')
if (( $l == $r ));then
echo $i
fi
done

Prime factors of first 100 integers

echo {1..100} | factor

Image:Screenshot from 2021-03-02 04-10-55.png

Personal tools
Strangers In Paradise