#!/usr/bin/perl -w use strict; my $amount = 1505; for my $mf ( 0 .. $amount/215 ) { my $amount2 = $amount - 215*$mf; for my $ff ( 0 .. $amount2/275 ) { my $amount3 = $amount2 - 275*$ff; for my $ss ( 0.. $amount3/335) { my $amount4 = $amount3 - 335*$ss; for my $hw ( 0.. $amount4/355) { my $amount5 = $amount4 - 355*$hw; for my $ms ( 0.. $amount5/420) { my $amount6 = $amount5-420*$ms; my $sp = int($amount6/580); print "$mf $ff $ss $hw $ms $sp\n" if $sp*580 == $amount6; } } } } }