Question: I am working on an application that retrieves photos from iOS photo library. When the photo is selected, I want to target a .xib to show an interface where the selected photo can be edited. 

However the build is failing due to this error:

> 
> "Unexpected interface name 'imageEditorView': expected expression"
> 
> 
> 

Here is the code:

```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
{
    [self dismissViewControllerAnimated:YES completion:^{
        [self.parentViewController presentViewController:imageEditorView: animated:YES completion:nil];
    }];
}

```

I have all the externals imported correctly in the .h files for both controllers. Any help would be greatly appreciated.

Answer: 
This is what you need

```
int f = 1;
int s = 0;
for (i = 1;i <= n;i++)
{     
    f *= i;
    s += f;
}

```

But i would suggest you look at your own code with a debugger to learn how things are working

Edit:

`for (i=1;i<=n;i++);` is equivalent to `i = n+1`

The block here is useless, you're just setting p to 1;

```
{
 p=1;    
}

```

In the following i is always `n+1` and `p` is always 1, so you are effectively doing `i+i+i...` for n times 

```
for (j=1;j<=i;j++)
{
   s=s+(p*i);
}

```
I think basically it need two loops, one for adding the factorial value, and an inner loop for calculating the factorial. 

```
#include <stdio.h>
int main (){
        int i,n,j,sum,factorial;
        printf("Put a number:");
        scanf("%d",&n);
        sum = 0;
        for (i=1;i<=n;i++){
                factorial = 1;
                for (j=2;j<=i;j++){
                        factorial *= j;
                }
                sum += factorial;
        }
        printf("\nSum=%d\n",sum);
        return 0;
}

```

But we can find that we don't need to calculate the factorial from 1 every time, because we can get factorial(n) from factorial(n - 1). So:

```
#include <stdio.h>
int main (){
        int i,n,j,sum,factorial;
        printf("Put a number:");
        scanf("%d",&n);
        sum = 0;
        factorial = 1;
        for (i=1;i<=n;i++){
                factorial *= i;
                sum += factorial;
        }
        printf("\nSum=%d\n",sum);
        return 0;
}

```

Also, you should do it better on code style and naming convention.