Question: I'm learning java looping, and managed to print a number one pattern using the for loop.
I tried printing the number one pattern using the while and do while loop, but had difficulty. This is my code:

```
for (int i = 0; i <= 7; i++) {
    for (int j = 0; j <= 4; j++) {
        if ((i == 0 && j > 1) || (i == 1 && j > 0) || (i == 2 && j >= 0) || (i == 3 && j > 1) || (i > 3 && j > 1))
            System.out.print("1");
        else
            System.out.print(" ");
    }

    System.out.println();
}

```

This is my while loop code:

```
int i = 0, j = 0;
        while (i <= 7) {
            while (j <= 4) {
                if((i == 0 && j > 1) || (i == 1 && j > 0) || (i == 2 && j >= 0) || (i == 3 && j > 1) || (i > 3 && j > 1))
                    System.out.print("1");
                else
                    System.out.print(" ");

                j++;
            }

            System.out.println();
            i++;
        }

```

[![this is my pattern](https://i.stack.imgur.com/twuVJ.png)](https://i.stack.imgur.com/twuVJ.png)

Answer: 
Do you actually need the leading zeroes?
You're experiencing one of the disadvantages of loosely-typed languages such as php or JavaScript: the interpretor decides what type is each variable, not you. It saves work most of the time because "it just works" but sometimes the data type chosen by the interpreter is not what you'd expect and you end up here.

You may think your args are either strings or integers with a lot of leading zeroes, but the interpreters are actually seeing Octal numbers (which, when converted to decimal, change)

Depending on what is the actual type you expect, you have many alternatives:

If you expect the argument to be treated as a string, you need to keep the leading zeroes but prevent any interpretation as octal like this

```
function approve(args)
{
var a = String(args); // force the type to string
if(confirm('Do you want to approve this document?'))
{
   window.location = "http://52.45.5.57/index.php/FinalizeCase/approve/" + a;

 }

else 
{
  return false;
}

```

Just to be safe, you may also want to take the value in your controller and cast it as a string too. Assuming the args is also called $args in your PHP part, you may do something like

```
public function approve( (string) $args = null)
{
    // Do whatever you need to do
}

```

This would also be my recommended course of action if your args are a zero-padded integer in the database.

If you need to considers args are strings, you should trim the leading zeroes and cast as int using `parseInt();` in JavaScript and/or `$args = (int) $args;` in php
Like @Funk Forty Niner said.

The solution is simple, just remove the leading zeroes.

```
$str = ltrim($str, '0');

```