Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I see a few problems:</p> <pre><code>try{ int t=Integer.parseInt(br.readLine()); }catch(IOException e){} int[] n=new int[t]; </code></pre> <p>Two problems there:</p> <ol> <li><p><code>t</code> is only declared within the <code>try</code> block. It's out-of-scope outside that block. Thus, a compile-time error trying to use <code>t</code> on the last line above.</p></li> <li><p>Even if you fix that by declaring <code>t</code> outside the block and then initializing it inside the block, the compiler can't be sure that <code>t</code> has a value as of the last line above. An exception may have been thrown instead. So that's an error (a compile-time error).</p></li> </ol> <p>The later, a third issue (at least):</p> <pre><code>for(int i=0;i&lt;n.length;i++) { try { n[i]=Integer.parseInt(br.readLine()); }catch(IOException e){} } </code></pre> <p>This is a logic error. If you try to use <code>n[i]</code> in your later loop, you have no idea whether <code>n[i]</code> has been actually initialized, because you've hidden your exception. For all you know, there was an I/O exception initializing <code>n[2]</code> and so <code>n[2]</code> keeps the default <code>null</code> value. If you try to use it later without checking for that, you'll get a <code>NullPointerException</code>.</p> <p>It's a <strong>really bad idea</strong> to catch and ignore exceptions, particularly doing it repeatedly for specific lines of code like that.</p> <p>Here's a minimal-changes reworking of that <code>main</code>:</p> <pre><code>public static void main(String args[]) { // Put all the code in one try block try { InputStreamReader in=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(in); int t=Integer.parseInt(br.readLine()); int[] n=new int[t]; for(int i=0;i&lt;n.length;i++) { n[i]=Integer.parseInt(br.readLine()); } for(int i=0;i&lt;n.length;i++) { int x=n[i]; BigInteger p = new BigInteger(Integer.toString(x)); p=smallfac.fac(p); System.out.println(p); } }catch(IOException e){ // Report the error here } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload