base-n series generator for a given number

ms_cs

ms_cs

@ms-cs-Ab8svl Oct 13, 2024
for example if my input is 2,then series shuould be, 00,01,10,11,etc.,
if my input is 10,then series shuould be,1,2,3,4,5,etc.,

is there any general mechanism in mathematics to find these numbers so that I can program for that

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Saandeep Sreerambatla

    Saandeep Sreerambatla

    @saandeep-sreerambatla-hWHU1M Jun 2, 2010

    In base 2 system using only 2 numbers you can get the maximum number as 3 which is 11.
    So my basic idea is ...
    using 4 digits as the number you can get the maximum number as 2[sup]4[/sup] - 1 = 15 using 4 numbers!

    Lets take 2 numbers only here..
    thus with base 2 system you can give numbers upto 2[sup]2[/sup] -1 = 3
    So the numbers are 00 , 01, 10, 11

    In base 3 system the maximum number we can represent is (22)[sub]3[/sub]
    thus the number is 3[sup]2[/sup]-1 = 8
    And this holds good for all the bases thus you can design a program which takes 2 inputs, the base and the number of digits which represent a number. By that you can design it.

    I hope you know how to convert numbers to any base system ?
  • silverscorpion

    silverscorpion

    @silverscorpion-iJKtdQ Jun 4, 2010

    If input is 2 you want 00,01,10 and 11 which are binary.
    If input is 10, you want 1,2,3 which is in decimal system.

    I'm confused.. Please clarify..
  • Morningdot Hablu

    Morningdot Hablu

    @morningdot-6Xuj4M Jun 4, 2010

    hey what you want to do.
    when input is decimal then output is binary series.
    and when input is binary output is decimal series.
    can you clearify your question.
  • Saandeep Sreerambatla

    Saandeep Sreerambatla

    @saandeep-sreerambatla-hWHU1M Jun 6, 2010

    silverscorpion
    If input is 2 you want 00,01,10 and 11 which are binary.
    If input is 10, you want 1,2,3 which is in decimal system.

    I'm confused.. Please clarify..

    @SS: As far as I understood , donot go with Decimal or binary naming conventions, the question is to get the numbers of the given base , infact the base -2 system is called Binary but that name is nothing to do with it!
    Since Decimal is called base -10 system , the question is to find the representation of numbers in given base.
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Jun 7, 2010

    why don't you use basic method of converting a no to any other base system

    ie by dividing no by n picking up remainder