Question: we have json data that is put into a custom object:

```
 "sentMoney": [
                {
                    "amount": 3840.83,
                    "currency": "MXN",
                    "isMajor": false
                },
                {
                    "amount": 200,
                    "currency": "USD",
                    "isMajor": true
                }
        ]

public final class SentMoney: NSCoding {
  public var currency: String?
  public var isMajor: Bool? = false
  public var amount: Double?
}

```

the custom object is then made reference to in a variable:

```
 public var sentMoney: [SentMoney]?

```

Now what we are trying to do is only get the FIRST amount (3840.83).

I tried doing it this way but there were errors:

```
 let amountsOnlyArray = self.postTransferSuccess?.sentMoney.map({ $0["amount"] })//Error -Cannot subscript a value of type '[SentMoney]' with an index of type 'String' 
 let firstAmountOnly = self.postTransferSuccess?.sentMoney![0]["amount"]//Error -Type 'BSentMoney' has no subscript members

```

Is there a better way to get that first amount?

Answer: 
```
if (i % j == 0) {
    isPrime = false;
    System.out.print(" ");
}

```

This if statement is always true for any `i` because `j` starts at 1. As a result, you print a space for every number < `n` and >= `2`

Also, `isPrime` may be an unnecessary variable.
I think is a logical problem in your script.
You should count with a loop all the number from 2 to n-1 which are = to 0 with a test 

```
n%i = 0

```

If the counter = 0 then no divider then prime number