+ 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 :)
13 RĂ©ponses
+ 5
Finally after 2 days on working this code I am finally posting it!!
https://code.sololearn.com/cfEQ75mYAtfa/?ref=app
+ 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 đ
+ 3
@baptiste now it's perfect :)
+ 3
after n
+ 1
Oh sorry, I'll correct it !
I misunderstood a point
+ 1
Done :)
+ 1
Here you go. Checks for valid input.
https://code.sololearn.com/cfF1MYbHQ0Q9/?ref=app
0
after n, or after n! ? That is a huge difference, actually.
- 1
TRY THIS BRAND NEW CHALLENGE AND GET FRESH..
https://www.sololearn.com/discuss/666260/?ref=app
- 1
HERE_IS_MY_NEW_CHALLENGE...
GET##FRESH##CHECK-IT-OUT
https://www.sololearn.com/discuss/668821/?ref=app
- 3
https://www.sololearn.com/discuss/663858/?ref=app