You are not logged in. Please login at to post your questions!


DEBNPRM - Editorial

Problem link:

Contest , Practice

Setter: Souradeep Paul

Tester: Debjit Datta




Dynamic Programming, Prime-sieve


Given a number, we have to find if its prime. If not we add the first prime number to it and check if its prime and then the second and so on until the sum becomes prime.

We use prime sieve and store all the prime numbers as false in a boolean array and composite numbers as true. Along with that we keep a list of all prime numbers upto 10^7. We check if the given number is prime and if not, we add the first number from the list to it and check again. The process goes on until we find a prime number.

Author’s and Tester’s Solution:

Author’s solution is here

Tester's solution is here

This question is marked "community wiki".

asked 02 Apr '18, 23:13

debjitdbb's gravatar image

accept rate: 0%

wikified 02 Apr '18, 23:14

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 02 Apr '18, 23:13

question was seen: 150 times

last updated: 02 Apr '18, 23:14