#!/usr/bin/perl #~~~~..{{:::::::::::::::::::::::::::{""""""""""""""""""""""""""""{{{{Divisibility #detection}}}}""""""""""""""""""""""""""""}:::::::::::::::::::::::::::}}..~~~~ # Written by: # DJ Amireh #A wonderful script that overcomplicates the simple task of detecting if a number is divisible by another number #It achieves this by using the rules of divisibility instead of just dividing and seeing if you get an integer answer #The rules of divisibility are rules that make it wasier for humans to find weather a number is divisible by another or not #This is generally not effecient for computers, but I'm doing it anyway! #I wrote this to learn more about perl by writing a fairly easy script use strict; #always use warnings; #always my $num; #number in question my $fir; #first few numbers my $tu; #boolean for divisible by two my $thr; #boolean for divisible by three my $furr; #boolean for divisible by four my $fii; #boolean for divisible by five my $sizz; #boolean for divisible by six my $nive; #boolean for divisible by nine my $tey; #boolean for divisible by ten my $all; #whole stack of divsibible numbers print "Welcome, this program will tell you weather a number is divisible by 1, 2, 3, 4, 5, 6, 9, or 10 by using the rules of divisibility./w"; #intro print "Please type the number in question./w"; #prompt $num = ; #get number chomp ($num); #have to, to remove \w thing after hitting enter #Check if number is divisible by 2 $fir = substr $num, 0, 1; #get first number if ($fir / 2 =~ (/^\d+$/)) { $tu = "TRUE"; $all = $all . "2";} #if the first number is divisible by 2 then the whole number is: make $tu true else { $tu = "FALSE"; } #otherwise it's false print $all; #list numbers $fir = ; #so the user can see the output