Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8599577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:25:38+00:00 2026-06-12T01:25:38+00:00

When compiling the program I get the error as Could not find the main

  • 0

When compiling the program I get the error as

Could not find the main class: Solution. Program will exit.

The program is:

import java.util.*;

public class Solution{
   public static long[] factors(long a){
     long[] b;
     b=new long[50];
     int count=0;
     for(long i=1L;i<=a/2;i++)
       if(a%i==0) b[count++]=i;
     return b;
   }

   public static void main(String[] args) {

        Scanner in=new Scanner(System.in);

        int N=in.nextInt();
        long K=in.nextInt();
        long[] fact=factors(K);
        l1:
        for(int i=0;i<N;i++)
        {
            long num=in.nextInt();
            for(int j=0;j<fact.length;j++)
                if(num%fact[j]==0 && fact[j]!=1) {fact[j]=1;continue l1;}

        }
        int result=0;
        for(int i=0;i<fact.length;i++)
            if(fact[i]!=1) ++result;
        System.out.println(result);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:25:39+00:00Added an answer on June 12, 2026 at 1:25 am

    This will not compile because the main method is not belong to a class. Put the main method inside the class to solve the problem. And your code is throwing arithmetic exception divide by zero should be fixed like that.

    for(int j=0;j<fact.length;j++)
      if (fact[j] != 0)
        if(num%fact[j]==0 && fact[j]!=1) {
          fact[j]=1;continue l1;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am compiling a simple program class Test { public static void main(String[] args)
import java.io.*; public class ArrayApp{ public static void main(String[] args){ System.out.println(lllll); } // end
I'm having trouble compiling a simple, sample program against glib on Ubuntu. I get
While compiling a program in Java I got this big WARNING warning: [unchecked] unchecked
I am compiling my program that will run on linux gcc 4.4.1 C99. I
I'm compiling a program on my 64bit machine, but I'm not sure if it
I am getting the following error while compiling a sample program in Qt 4.5
I'm have horrendous problems trying to get a JOGL program compiling using Netbeans 6.9.
The problem: I can't get my java app to run after compiling. My guess
OK, I just cannot get java to run my .class files: I follow steps

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.