This code takes my file with a key ordered list of prime numbers and pushes each prime onto @prime. It then asks the user to specify to keys to multiply together and prints the result. I was about to handle some very large numbers with this.open (FILE, 'pout.txt') || die "Could not open output:\n $!\n"; $i = 0; while (<FILE>){ chomp($_); ($key, $prime) =split (/ /, $_); push (@prime, $prime); } $nop = @prime; print "$nop primes found.\n"; $i = 0; until ( $i == 1) { print "Enter First Key\: "; $key1 = <STDIN>; chomp ($key1); print "Enter Second Key\: "; $key2 = <STDIN>; chomp ($key2); $total = (@prime[$key1] * @prime[$key2]); print "@prime[$key1] times @prime[$key2] is $total\n"; }
In reply to Re: perls long number problem
by sparkyichi
in thread perls long number problem
by toadi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |