Posts

Showing posts from December, 2020

EUROPEAN ITERATION

  We know about number systems: The Roman numerals and the alternative place-value system with a given base. For the purposes of this problem, we limit ourselves to Roman numerals with values up to 3999  MMMCMXCIX "Place value system" numbers having bases from 2 (with possible symbols 0, 1) through 36 (with possible symbols 0, 1, ..., 9, A, ... ,Z) Consider the following procedure: Accept a natural number  N  (in base 10). If N lies in the closed interval [1,3999], i.e. between 1 and 3999 (both inclusive), convert  N  to  R , its Roman numeral representation; else output  N  as the result and stop. Identify the base in which the value of R, now considered to be in "place value system", is least and calculate its value in base 10, replacing N with this value. Repeat from step 2. Constraints 1 <= N <= 3999 Input Format A single Integer  N . Output Converted  N Test Case Example Input 1 Output 45338950 Explanation The procedure g...

Consecutive Prime Sum

  Some prime numbers can be expressed as Sum of other consecutive prime numbers. For example 5 = 2 + 3 17 = 2 + 3 + 5 + 7 41 = 2 + 3 + 5 + 7 + 11 + 13 Your task is to find out how many prime numbers which satisfy this property are present in the range 3 to N subject to a constraint that summation should always start with number 2. Write code to find out number of prime numbers that satisfy the above mentioned property in a given range. Input Format: First line of input contains  k  - the number of inputs The next  k  lines contains a number N. Output Format: Print the total number of all such prime numbers which are less than or equal to N. Example: Input: k = 2 N = 20 N = 15 Output: 2 (there are 2 such numbers: 5 and 17) 1 Solution: def isprime(p):     if(p==0):         return 0     elif(p==1):         return 0     else:         for i in range(2,int(p**.5)+2):   ...