1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Puzzle for 25 Jun 2009

Discussion in '$1 Daily Competition' started by shabbir, Jun 25, 2009.

  1. shabbir

    shabbir Administrator Staff Member

    Find a three digit prime number which

    • Has all prime digits
    • Forms primes with its first two digits.
    • Forms primes with its last two digits.
     
  2. nimesh

    nimesh New Member

    I say 373

    Has all prime digits - All are Prime 3, 7
    Forms primes with its first two digits - Forms Prime with first 2 digits 37
    Forms primes with its and last two digits. - Forms Prime with Last two - 73

    The last condition looks incomplete.
    There was no condition of uniqueness of digits
    There was no condition like least 3 digit prime :)
     
  3. Mridula

    Mridula New Member

    179 - 3 unique digit prime no.

    17 is a prime no.
    79 is prime no.
     
  4. nimesh

    nimesh New Member

    But 1 is not a prime no :lol:
    Sorry Mridula for Yesterday
     
  5. shabbir

    shabbir Administrator Staff Member

    Like.
    Dont confuse with yesterdays problem and its a fresh one with not any condition.

    I would like to also see a reason as to how you landed to the number you have as answer.
     
  6. nimesh

    nimesh New Member

    "The last condition looks incomplete."
    I mean the sentence formation is incorrect. Which you have corrected now...haha

    What reason would you like? [btw, you didn't asked earlier to specify the reason]
    I just looked at the list of prime numbers and checked with the conditions you gave.

    Other numbers that I thought were:
    113, 131, 137, 173, 197, 311, 313, 317 - But 1 is not a prime number
    So the first number that I got was 373
     
  7. xpi0t0s

    xpi0t0s Mentor

    All possible results are
    237
    373
    537
    737

    Code:
    int is_prime(int n)
    {
    	if (n==2) return 1;
    	if (n<3) return 0;
    	if (!(n%2)) return 0;
    	for (int i=3; i*i<=n; i+=2)
    	{
    		if (!(n%i))
    			return 0;
    	}
    	return 1;
    }
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	for (int i=100; i<1000; i++)
    	{
    		int digits[3];
    		int temp=i;
    		digits[2]=temp%10; temp/=10;
    		digits[1]=temp%10; temp/=10;
    		digits[0]=temp%10;
    		temp=i;
    		int ms100,ls100;
    		ms100=digits[0]*10+digits[1];
    		ls100=digits[1]*10+digits[2];
    		if (is_prime(digits[0]) && is_prime(digits[1]) && is_prime(digits[2]))
    		{
    			if (is_prime(ms100) && is_prime(ls100))
    			{
    				printf("%d\n",i);
    			}
    		}
    	}
    	return 0;
    }
    
     
  8. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    LOL @ xpi0t0s, you brute-forced the solution for such a simple question !!
    I mean, shabbir didn't even mention the word "smallest". So, that was really easy to figure out a 3-digit number.

    Congrats nimesh.

    @ shabbir:
    So, you changed the posting time today (by almost -12 hours) !! :(
    I'll have to wait till 2morrow.
     
    Last edited: Jun 25, 2009
  9. nimesh

    nimesh New Member

    xpi0t0s - 237 is not a prime number (237 = 3 * 79) List of Prime Numbers

    Thanks Saswat, but the winner is not yet confirmed by Shabbir :)
     
  10. xpi0t0s

    xpi0t0s Mentor

    Whoops, you're right, neither are 537 and 737 so the only result is 373. Adding
    Code:
    if (is_prime(i))
    
    fixed the problem.
     
  11. xpi0t0s

    xpi0t0s Mentor

    Yes Saswat I brute forced it. I'm obviously not up to your standards.
     
  12. shabbir

    shabbir Administrator Staff Member

    Yes. It was not conditional error but a typo.

    Just curious. Nothing to with the competition

    So its not predictable. :D

    Logic is also there. 2,3,5,7 are the digits which needs to be filled in the 3 slots.

    • 2 and 5 cannot come in the last slot other wise number would not be prime, so it has to be 3 and 7.
    • With the above logic 2 and 5 also cannot come in the second slot as the number with those should also be prime.
    • Any combination of 5,3,7 or 2,3,7 is divisible by 3
    • 7 and 3 cannot be at consecutive places as we need primes by both the numbers.
    • so the option left is 373 and 737
    • 737 is not prime
    Winner is Nimesh and I did not mention smallest largest anything because I knew it has unique solution
     
    nimesh likes this.
  13. nimesh

    nimesh New Member

    Cool...
    Nice explanation Shabbir. I like it.:2thumbsup
     
  14. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    So, you have implemented a manual version of my random posting time idea :D
     
  15. shabbir

    shabbir Administrator Staff Member

    To an extent.
     

Share This Page