1. Write a program that takes an integer $n$ and displays the value of $U_n$ respecting: 
    $U_1=1$ ;
    $U_n=\sum_{i=1}^{n-1}\frac{U_i}{(i-1)!}$ for n>0 ;
  2. Write a program that asks the user to enter an integer a and then prints the series elements from $U_1$ to $U_a$.

 


Difficulty level
This exercise is mostly suitable for students
#include<stdio.h>
#include<math.h>

int main()
{
	int N, count, x ,y ,xmax,ymax;
	double R, dist, dmax;
    
    count = 0;
    
    dmax = xmax=ymax=0;
     
     do{
        printf("Enter N: ");
	    scanf("%d", &N);
     }while(N<0);
	 
	 printf("Enter R: ");
	 scanf("%lf", &R);
	    
    do{
        printf("Enter coordinates x and y: ");
	    scanf("%d %d", &x, &y);
	    dist = sqrt(pow(x,2)+pow(y,2));
        if(dist<R)
            count++;
        if(dist>dmax)
        {
            dmax=dist;
            xmax=x;
            ymax=y;
        }
    }while(count<N);	   
 
    printf("Farthest point is (%d,%d)\n",xmax,ymax);
 
	return 0;
}

 

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Sorting using merge-sort algorithm