Friday, February 1, 2019

Prime Generator-2

  • Problem Description

    Write a program to find prime numbers between two range excluding the starting and ending number of given range

    Input 1: Lower Range

    Input 2: Upper Range

    Output:
    List of prime numbers

    Refer sample input and output for formatting specification.
  • CODING ARENA
  • lower=int(input())
    upper=int(input())
    for num in range(lower,upper + 1):
       if num > 1:
           for i in range(2,num):
               if (num % i) == 0:
                   break
           else:
               print(num)
  • Test Case 1

    Input (stdin)
    17
    
    23
    
    
    Expected Output
    17
    
    19
    
    23
  • Test Case 2

    Input (stdin)
    11
    
    31
    
    
    Expected Output
    11
    
    13
    
    17
    
    19
    
    23
    
    29
    
    31

No comments:

Post a Comment