Same digits, again?

I have an integer n n in my mind which satisfies following properties:

  • The reciprocal m m of n n is a non-terminating recurring decimal
  • The recurring digits of m m forms a number p p . For example, recurring digits of reciprocal of 13 forms a number 769230 and digits of reciprocal of 9 forms 1. (Move 0 to the end if it appears at first place as I did in case of 13)
  • p p is the smallest number such that the digits of p p are same as that of 2 p , 3 p , 4 p , 5 p 2p,\ 3p,\ 4p,\ 5p and 6 p 6p

Enter your answer as p + n p+n


Here are My CS Problems


The answer is 142864.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

5 solutions

Pranjal Jain
Mar 23, 2015

Note that p p must be in [ 1 0 n , ( 5 3 ) × 1 0 n ] \left [10^n,\left (\dfrac{5}{3}\right )\times 10^{n}\right ] as the number of digits in p p and 6 p 6p are same.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
from math import floor
def ndigits(x):
    """Calculates number of digits in the number"""
    n=0
    while(x!=0):
        n+=1
        x=x//10
    return n
for n in range(0,8):
    for p in range(10**n,floor((5/3)*(10**n)):
        if ndigits(p)==ndigits(2*p):
            if ndigits(p)==ndigits(3*p):
                if ndigits(p)==ndigits(4*p):
                    if ndigits(p)==ndigits(5*p):
                        if ndigits(p)==ndigits(6*p):
                            print(p)
                            break

It returns 142857

Now, m = 0.142857142857... = 0. ( 142857 ) = 1 7 m=0.142857142857...=0.(142857)=\dfrac{1}{7}

Thus, n = 7 n=7

I believe there is some faster method.

TBH I didn't know abt the smallest such number thing .

I knew of it from when once I had wrongly proved that π \pi is a non-terminating recurring number by wrongly assuming that π = 22 7 \pi=\dfrac{22}{7} is accurate !

And then this number had me quite fascinated .

I'll be waiting for your solution :)

A Former Brilliant Member - 6 years, 2 months ago

Log in to reply

Done! Anyways I was wonderinng if some p is there such that its digits matches with 7 p 7p as well, but couldn't find it. Moreover, 142857 142857 is the smallest number whose digits matches with only 2 p 2p and 3 p 3p , 4 p , 5 p , 6 p 4p,5p,6p are just in addition.

Pranjal Jain - 6 years, 2 months ago

Log in to reply

Well the way you have solved it , it's difficult to use it to find the same for 7 p 7p and btw I mostly use Java , so it'll be quite difficult for me to do the same .

But I think I can manage it , I'll try this question out too .

Also , nice Profile Pic ! It's been quite a few months since I lasted watched Pokemon ¨ \displaystyle \ddot\frown , I hope I'll get a lot time after JEE Advanced to do so !

A Former Brilliant Member - 6 years, 2 months ago

Log in to reply

@A Former Brilliant Member I am a big fan of Pokemon. Especially Indigo League and Orange League.

As for the 7 p 7p , you just have to add one more if ndigits(p)==ndigits(7*p) , and reduce the max limit to 10 7 × 1 0 n \dfrac{10}{7}\times 10^n . Also I forgot to add function ndigits from my custom library. I hope you'll understand my solution now.

Pranjal Jain - 6 years, 2 months ago

Log in to reply

@Pranjal Jain Well then I'm a bigger fan :P

Did you ever play any of the Pokemon games on Game Boy Advance , Nintendo DS or any game station or their Emulator equivalents ?

I have played :

  • Pokemon HeartGold (Johto Region)

  • Pokemon LeafGreen (Kanto Region)

  • Pokemon Sapphire , Emerald (Hoenn Region)

  • Pokemon Diamond , Platinum (Sinnoh Region)

  • Pokemon Black 2 (Unova Region)

Yep! I play (used to until quite recently) a lot of games . But I guess you are the studious type , right ?

A Former Brilliant Member - 6 years, 2 months ago

Log in to reply

@A Former Brilliant Member Lol NOO!! I am talking about television series. @5 PM

Pranjal Jain - 6 years, 2 months ago

Log in to reply

@Pranjal Jain There has to be a meme on Pokemon and 5 PM, they are so closely related!

Kartik Sharma - 6 years, 2 months ago

Log in to reply

@Kartik Sharma Why do you say so?

A Former Brilliant Member - 6 years, 2 months ago

@Pranjal Jain Yeah , I too have watched all the seasons of Pokemon till Diamond and Pearl . Didn't get enough time to watch Pokemon X and Y but I made up for it by playing the game .

You know you can maybe try the games after you get into an IIT , those are among the "must play" games of the this century !

A Former Brilliant Member - 6 years, 2 months ago

Log in to reply

@A Former Brilliant Member I know I should and I will!!

Pranjal Jain - 6 years, 2 months ago

@A Former Brilliant Member Oh, well I see you haven't played the most famous of them - The Fire red of course. I used to play that plus Emerald. BTW, you have played a lot of them. I used to play on emulators, actually. Did you play on game stations? Interesting! I thought no one bought those consoles. And yeah, after Sinnoh, Pokemon just vanished, ah! How can children of these days rely on those baseless stupid Indian animated cartoons(in the usual case)?!

Kartik Sharma - 6 years, 2 months ago

Log in to reply

@Kartik Sharma Actually I don't own any of the gaming consoles so I had to stick with emulators !

Yes , I remember those beautiful childhood days of mine when I would want to rush home from school and sit down to watch the Detective Conan show at 3:00 pm then the Power Rangers Series on Jetix (I have watched all the good ones in the series , the list is provided below) followed by POKEMON at 5:00 ! Those were the days !

The list of Power Rangers series that I have watched :

  • Power Rangers Wild Force (the first one that I watched)

  • Power Rangers Time Force

  • Power Rangers Ninja Storm

  • Power Rangers Dino Thunder

  • Power Rangers SPD

  • Power Rangers Mystic Force (the one I liked the most !)

Most of the latest Power Rangers series post Mystic Force were just some boring dramas without any proper storyline .

P.S. I don't know why but I feel no one will be interested in this stuff , but I thought I should post it anyway .

A Former Brilliant Member - 6 years, 2 months ago

@A Former Brilliant Member @Azhaghu Roopesh M @Kartik Sharma @Pranjal Jain Good to know that there are other pokemon fans around here! My personal favorite is Emerald, especially it's cloning glitch. My friends and myself started playing this since class 5. I own a Gameboy advance SP(can't find it now :( ), and a DS lite. I have original casettes of Emerald, leafgreen and Diamond. Here are the games I have played:

Kanto: Red, Green, Yellow, firered,leafgreen(twice)

Johto: Crystal, Gold, Heartgold, Soulsilver

Hoenn: Ruby(twice), Saphire, Emerald(4 times)

Sinnoh: Diamond, Platinum

Unova: Black, white(halfway, regret not finishing it)

I scolded my brother for misplacing the gameboy. Tried my DS after years, still works! Diamond, a hundred and seventeen hours of gameplay!

Raghav Vaidyanathan - 6 years, 2 months ago

For 7 p 7p - 94 , 95 , 97 94,95,97

Kartik Sharma - 6 years, 2 months ago

Log in to reply

@Kartik Sharma You mean the values of n n ?

Pranjal Jain - 6 years, 2 months ago

Log in to reply

@Pranjal Jain Yeah! They are n n !

Kartik Sharma - 6 years, 2 months ago

@Pranjal Jain @Azhaghu Roopesh M

I knew this property beforehand as used to(still do) play with my calculator a lot. Nice question!

0.142857142857142857... 0.142857142857142857...

Raghav Vaidyanathan - 6 years, 2 months ago

Log in to reply

Oh thats nice. ¨ \ddot\smile

Pranjal Jain - 6 years, 2 months ago

Yeah , me too :)

A Former Brilliant Member - 6 years, 2 months ago

Do you experiment with a graphing calculator too ? I enjoy trying out random equations and plotting their graphs .

A Former Brilliant Member - 6 years, 2 months ago

Log in to reply

I do! I use Algeo on Android for it. Its fun to use floor/frac+exponents/trigonommetric.

Pranjal Jain - 6 years, 2 months ago

Log in to reply

@Pranjal Jain Cool . Btw I use Quick Graph on my iPad , the same one that @Trevor Arashiro uses(only diff. being that he has the full version while I don't) .

Do you know of a graphing Calc. for Windows ? You know so that I can use it on my Laptop . I don't want to use Desmos since it doesn't work most of the time (for me at least) and also needs Internet connection . I wanted an offline software that can be used anytime .

Also try out the graphs of non-integrable functions like sin x x \dfrac{\sin x}{x} and logarithm of trigonometric functions! I think I'll upload a pic once I return from the exam hall .

Best of Luck to you :)

A Former Brilliant Member - 6 years, 2 months ago

Log in to reply

@A Former Brilliant Member Geogebra works on Windows. And yes I have plotted these functions already.

Pranjal Jain - 6 years, 2 months ago

Log in to reply

@Pranjal Jain Thanks ¨ \ddot\smile

A Former Brilliant Member - 6 years, 2 months ago

@A Former Brilliant Member Try csc ( x ) csc ( y ) = 2 \csc(x)\csc(y)=2

Trevor Arashiro - 6 years, 2 months ago

Log in to reply

@Trevor Arashiro

Pranjal Jain - 6 years, 2 months ago

@Pranjal Jain , I didn't need even 10 seconds to solve this after reading the question, because what I was taught in std 9 9 , one of the fascinating things (for that age) , while they taught how to write a decimal recurring thing in fraction form.... that was 142857 142857 , when it came in 1 7 \dfrac{1}{7}

You write it's table, and you see that

142857 142857

285714 285714

428571 428571

571428 571428

714285 714285

857142 857142

999999 999999

Not just the digits are same, they are like cyclic... also, their first 2 digits are very much related to the table of 14 14 .... So cool!

Aditya Raut - 6 years, 2 months ago

Check out my solution! @Pranjal Jain

Kartik Sharma - 6 years, 2 months ago
Abdelhamid Saadi
Jan 14, 2017
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
"Same digits, again?"
p = 0
found = False
while not found:
    p += 1
    s = set(str(p))
    if (set(str(2*p)) == s
        and set(str(3*p)) == s
        and set(str(4*p)) == s 
        and set(str(5*p)) == s
        and set(str(6*p)) == s):
        found = True
print(p)

print(p+7)

David Holcer
Apr 12, 2015
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
def digits(c):
    array=[]
    for i in str(c):
        array.append(int(i))
    return array
c=1
while True:
    works=True
    for i in xrange(1,6):
        if set(digits(c*i))==set(digits(c*(i+1))) and works:
            works=True
        else:
            works=False
    if works:
        print c
        break
    c+=1

This just gives us smallest p (142857), and obviously 1/7=.142857 so n=7 and p+n=142864

Aryan Gaikwad
Mar 24, 2015

I knew the answer even before writing the code but I still gave a go at it. Here's my solution in Java -

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*First find  p and then check if p is present in recurring digits of m*/
public static void main(String args[]){
    String ans;
    for(int i = 1;;i++)
        if(chk(i)){
            ans = Integer.toString(i);
            break;
        }
    for(int i = 1;;i++)
        if(String.valueOf((double) 1/i).contains(ans)){
            System.out.println(i);
            break;
        }
}
static boolean chk(int n){
    String ar[] = new String[6];
    for(int i = 1; i <= 6; i++)
        ar[i-1] = Integer.toString(n * i);
    for(int i = 0; i < 6; i++){
        char[] c = ar[i].toCharArray();
        Arrays.sort(c);
        ar[i] = new String(c);
    }
    return ar[1].equals(ar[0]) && ar[1].equals(ar[2]) && ar[1].equals(ar[3]) && ar[1].equals(ar[4]) && ar[1].equals(ar[5]);
}

It takes about 0.1 second to run on my machine.

Nice method , it's similar to what I would have done .

Btw how do you know Java at the age of 14 ? Also do you use an IDE ? Netbeans perhaps ? If so , which version ?

A Former Brilliant Member - 6 years, 2 months ago

Log in to reply

I started with JavaScript and HTML when I was 8 and learned Java when I was 13.

I use NetBeans IDE 8.0.2 and sometimes Geany (Linux's text editor which also provide basic features of IDE) as it's faster to start and work with.

Aryan Gaikwad - 6 years, 2 months ago

Log in to reply

Wow! You sure have had a great start to a coder's life .

Currently I am stuck with Netbeans IDE 6.5.1 but once my exam gets over(the day after tomorrow) I'll start with 8.0.2 too .

Is JavaScript easy if you know Java ? I have heard a lot about it's use in Web designing and am interested to learn it . What say ?

A Former Brilliant Member - 6 years, 2 months ago

Log in to reply

@A Former Brilliant Member Thanks!

JavaScript is prototype-based while Java is class based. Also, JavaScript uses functions instead of methods so there is a little difference in syntax, but both almost work the same way. Apart from that, the basic syntax is quite similar and although some new concepts are introduced in JavaScript, they are easy to understand.

So I would say JavaScript would be quite easy to learn for you and I really think you should give a go at it. Best of luck for it!

Aryan Gaikwad - 6 years, 2 months ago

Log in to reply

@Aryan Gaikwad Thanks , I'll definitely go for it .

A Former Brilliant Member - 6 years, 2 months ago
Kartik Sharma
Mar 24, 2015
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 def reci_recurr(n):
    getcontext().prec = 2*n+2
    x = Decimal(1)/Decimal(n)
    y = x*(10**(2*n+2))
    z = list(str(y))
    for i in range(n):
        S  = ''
        for j in range(i):
            S = S + z[j]
        T  = ''
        for k in range(len(S), 2*len(S)):
            T = T + z[k]
        if T == S and S != '':
            return int(S)
for a in range(1,100):
    g = reci_recurr(a)
    if g != None:
    if(sorted(str(g))==sorted(str(2*g))==sorted(str(3*g))==sorted(str(4*g))==sorted(str(5*g))==sorted(str(6*g))):
            print a

7

61

70

71

94

95

97

98

Which version of python are you using? I am using 3.4.2 to get name 'getcontext' is not defined

Pranjal Jain - 6 years, 2 months ago

Log in to reply

Really? I am using 2.7.5! Still, no getcontext! That's interesting! Maybe it is replaced by something else.

Kartik Sharma - 6 years, 2 months ago

Log in to reply

Yeah 3.x is quite different from 2.x, there is no xrange even.

Pranjal Jain - 6 years, 2 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...