Friday, February 1, 2019

Prime Generator-1

  • Problem Description

    Write a program to find prime numbers between two 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+1,upper):
       if num > 1:
           for i in range(2,num):
               if (num % i) == 0:
                   break
           else:
               print(num)
  • Test Case 1

    Input (stdin)
    11
    
    31
    
    
    Expected Output
    13
    
    17
    
    19
    
    23
    
    29
  • Test Case 2

    Input (stdin)
    7
    
    15
    
    
    Expected Output
    11
    
    13

No comments:

Post a Comment