Codecademy Forums

What about it?

Instructions- Read It carefully**(I got a null result)**

1.

We’re going to do a mathematical “magic” trick. Create a variable, $my_num and assign as its value any number.

Next, create a second variable, $answer and assign $my_num as its value.

Stuck? Get a hint

2.

Use the addition assignment operator to add 2 to $answer .

Hint

The point here is to practice using the handy mathematical assignment operators:

$example += 9;

3.

Use the multiplication assignment operator to multiply $answer by 2.

Stuck? Get a hint

4.

Use the subtraction assignment operator to subtract 2 from $answer .

Stuck? Get a hint

5.

Use the division assignment operator to divide $answer by 2.

Stuck? Get a hint

6.

Almost there. Use the subtraction assignment operator to subtract your original number ( $my_num ) from $answer . Finally, use echo to print $answer to the terminal.

If everything went as it should, $answer should be 1. No matter what your original number was! Don’t belive us? Go ahead try it with a different number for the value of $my_num .

Here my code,

<?php
// Write your code below:

  $my_num=100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000;

  $answer=$my_num;
  $answer+=2;
$answer*=2;
$answer-=2;
$answer/=2;
$answer-=$my_num;
echo $answer;