@record;
for ($i=1;$i<50;$i++)
{
$w,$x,$y,$z,$s,$buf,$x_mem;
$x=int(rand(100));
$x_mem=$x;
$y=int(rand(50));
if ($x%2==0)
{
$buf=int(rand($x)); #less
$x=$x-$buf;
$x_mem=$x_mem.'-'.$buf;
}
else
{
$buf=int(rand($x)); #greater
$x=$x+$buf;
$x_mem=$x_mem.'+'.$buf;
}
$s=$x+$y;
if ($s>100)
{
#print "greater\n";
$z='-'.($s-100);
}
elsif($s==100)
{
#print "equal\n";
$z=0;
}
else
{
#print "less\n";
$z='+'.(100-$s);
}
$tmp="$x_mem+$y$z"."=100\n";
if ( grep( /^$tmp$/, @array ) ) {
print "repeated";
}
else
{
print $tmp;
push(@record,"$x_mem+$y$z"."=100\n")
}
}
This piece of code will generate a mathematical equation which on solving will give the value 100.
eg. 45+32+29-6=100
eg. 45+32+29-6=100
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.