"""simple docstring"""


import math






def      __UpperCAmelCase       (      lowercase		):







  """simple docstring"""

  if not isinstance(lowercase ,lowercase		):
    _UpperCAmelCase    			=   f'''Input value of [number={number}] must be an integer'''
    raise TypeError(lowercase		)

  if number < 1:
    _UpperCAmelCase    			=   f'''Input value of [number={number}] must be > 0'''
    raise ValueError(lowercase		)
  elif number == 1:
    return 3
  elif number == 2:
    return 5
  else:
    _UpperCAmelCase    			=   int(math.log(number // 3 ,2		)		) + 2

    _UpperCAmelCase    			=   [3, 5]
    _UpperCAmelCase    			=   2
    _UpperCAmelCase    			=   3
    for block in range(1 ,lowercase		):
      for _ in range(lowercase		):
        proth_list.append(2 ** (block + 1) + proth_list[proth_index - 1]		)
        proth_index += 1
      increment *= 2

  return proth_list[number - 1]


if __name__ == "__main__":
    import doctest

    doctest.testmod()

    for number in range(1_1):
        UpperCAmelCase__			=    0
        try:
            UpperCAmelCase__			=    proth(number)
        except ValueError:
            print(F'''ValueError: there is no {number}th Proth number''')
            continue

        print(F'''The {number}th Proth number: {value}''')

"""simple docstring"""


import pytest

from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs






@pytest.mark.parametrize(
    """kwargs, expected""" ,[
        ({"""num_shards""": 0, """max_num_jobs""": 1}, []),
        ({"""num_shards""": 10, """max_num_jobs""": 1}, [range(10		)]),
        ({"""num_shards""": 10, """max_num_jobs""": 10}, [range(lowercase ,i + 1		) for i in range(10		)]),
        ({"""num_shards""": 1, """max_num_jobs""": 10}, [range(1		)]),
        ({"""num_shards""": 10, """max_num_jobs""": 3}, [range(0 ,4		), range(4 ,7		), range(7 ,10		)]),
        ({"""num_shards""": 3, """max_num_jobs""": 10}, [range(0 ,1		), range(1 ,2		), range(2 ,3		)]),
    ] ,)
def      __UpperCAmelCase       (      lowercase ,lowercase		):







  """simple docstring"""
  _UpperCAmelCase    			=   _distribute_shards(**lowercase		)
  assert out == expected






@pytest.mark.parametrize(
    """gen_kwargs, max_num_jobs, expected""" ,[
        ({"""foo""": 0}, 10, [{"""foo""": 0}]),
        ({"""shards""": [0, 1, 2, 3]}, 1, [{"""shards""": [0, 1, 2, 3]}]),
        ({"""shards""": [0, 1, 2, 3]}, 4, [{"""shards""": [0]}, {"""shards""": [1]}, {"""shards""": [2]}, {"""shards""": [3]}]),
        ({"""shards""": [0, 1]}, 4, [{"""shards""": [0]}, {"""shards""": [1]}]),
        ({"""shards""": [0, 1, 2, 3]}, 2, [{"""shards""": [0, 1]}, {"""shards""": [2, 3]}]),
    ] ,)
def      __UpperCAmelCase       (      lowercase ,lowercase ,lowercase		):







  """simple docstring"""
  _UpperCAmelCase    			=   _split_gen_kwargs(lowercase ,lowercase		)
  assert out == expected






@pytest.mark.parametrize(
    """gen_kwargs, expected""" ,[
        ({"""foo""": 0}, 1),
        ({"""shards""": [0]}, 1),
        ({"""shards""": [0, 1, 2, 3]}, 4),
        ({"""shards""": [0, 1, 2, 3], """foo""": 0}, 4),
        ({"""shards""": [0, 1, 2, 3], """other""": (0, 1)}, 4),
        ({"""shards""": [0, 1, 2, 3], """shards2""": [0, 1]}, RuntimeError),
    ] ,)
def      __UpperCAmelCase       (      lowercase ,lowercase		):







  """simple docstring"""
  if expected is RuntimeError:
    with pytest.raises(lowercase		):
      _number_of_shards_in_gen_kwargs(lowercase		)
  else:
    _UpperCAmelCase    			=   _number_of_shards_in_gen_kwargs(lowercase		)
    assert out == expected
