+ 5

Challenge: fortunate number

a fortunate number (NOT to be confused with lucky number!!!) x>n is the smallest natural number that, if added to the product of all prime numbers from 1 to n, gives another prime number. example: assuming n is 17, the product of prime numbers from 1 to 17 is 510510. if we add 18 to 510510 we don't have a prime number (510528 is not prime), so we skip 18 and go to 19 that (surprise!!!) is a fortunate number because 510529 is prime! task: write a code that, once user inputs a natural integer n, finds the first fortunate number after n! enjoy :)

28th Aug 2017, 11:44 AM
Luca
Luca - avatar
13 RĂ©ponses
+ 5
Finally after 2 days on working this code I am finally posting it!! https://code.sololearn.com/cfEQ75mYAtfa/?ref=app
7th Oct 2017, 12:00 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 3
@baptiste thank you for answering 😊 just tried your code with the provided example, but the fortunate number is non 510529, it's 19 ad it's the smallest integer after 17 ti create a prime if added to product of all prime numbers till 17 🙃 it should be an easy fix anyway 😊
28th Aug 2017, 12:51 PM
Luca
Luca - avatar
+ 3
@baptiste now it's perfect :)
28th Aug 2017, 12:54 PM
Luca
Luca - avatar
+ 3
after n
29th Aug 2017, 5:42 AM
Luca
Luca - avatar
28th Aug 2017, 12:47 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
28th Aug 2017, 1:49 PM
ysraelcon
ysraelcon - avatar
+ 1
Oh sorry, I'll correct it ! I misunderstood a point
28th Aug 2017, 12:52 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
Done :)
28th Aug 2017, 12:53 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
Here you go. Checks for valid input. https://code.sololearn.com/cfF1MYbHQ0Q9/?ref=app
19th Sep 2017, 12:56 AM
Vari93
Vari93 - avatar
0
after n, or after n! ? That is a huge difference, actually.
29th Aug 2017, 3:35 AM
Amaras A
Amaras A - avatar
- 1
TRY THIS BRAND NEW CHALLENGE AND GET FRESH.. https://www.sololearn.com/discuss/666260/?ref=app
28th Aug 2017, 5:38 PM
sayan chandra
sayan chandra - avatar
- 1
HERE_IS_MY_NEW_CHALLENGE... GET##FRESH##CHECK-IT-OUT https://www.sololearn.com/discuss/668821/?ref=app
29th Aug 2017, 5:33 PM
sayan chandra
sayan chandra - avatar
- 3
https://www.sololearn.com/discuss/663858/?ref=app
29th Aug 2017, 11:53 AM
Raksha Chandwani
Raksha Chandwani - avatar