Count special numbers between boundaries (100 Marks)
Input Format
For this challenge, you need to take two integers on separate lines. These numbers defines the range.Constraints
1 < = ( a , b ) < = 100000Output Format
output will be the single number which tells how many prime numbers are there between given range.Sample TestCase 1
Input
120
Output
8
Explanation
There are 8 prime numbers which lies in the given range.
They are 2, 3, 5, 7, 11, 13, 17, 19
- Time Limit(X):
- 1.00 sec(s) for each input.
- Memory Limit:
- 512 MB
- Source Limit:
- 100 KB
- Allowed Languages:
- C, C++, C++11, C++14, C#, Java, Java 8, PHP, PHP 7, Python, Python 3, Perl, Ruby, Node Js, Scala, Clojure, Haskell, Lua, Erlang, Swift, VBnet, Js, Objc, Pascal, Go, F#, D, Groovy, Tcl, Ocaml, Smalltalk, Cobol, Racket, Bash, GNU Octave, Rust, Common LISP, R, Julia, Fortran, Ada, Prolog, Icon, Elixir, CoffeeScript, Brainfuck, Pypy, Lolcode, Nim, Picolisp, Pike
SOLUTION DAY-07: (100 Marks)
def main():
num1=int(input("Enter num 1:"))
num2=int(input("Enter num2: "))
c=0
for num in range(num1,num2+1):
if num>1:
for i in range(2,num):
if num%i==0:
break
else:
c+=1
print(c)
main()
No comments:
Post a Comment