Sort by

recency

|

470 Discussions

|

  • + 0 comments

    You can optimize by going only up to sqrt(n) and adding both the factors at once (similar principal when looking for Prime numbers).

        public int divisor_sum(int n) {
            if(n==1) return 1;
            int sum=0;
            for(int i=1; i * i <= n; i++) {
                if(n%i==0) {
                    sum += i;
                    sum += n/i; //other factor of a * b = n
                }
            }
            return sum;
        }
    
  • + 0 comments

    This website is shit bro.

  • + 0 comments

    Here is java Interface solution - https://programmingoneonone.com/hackerrank-java-interface-problem-solution.html

  • + 0 comments

    Rummy is a game of strategy, where players must plan and execute their moves carefully to outsmart their opponents. Players need to think ahead, decide which cards to keep and which to discard, and form sets and sequences while also predicting the moves of others. This process of strategic planning strengthens decision-making abilities click here to get the latest version of the app, as players are constantly assessing the potential outcomes of their actions. Such strategic thinking can be transferred to real-life situations, helping players make more informed and thoughtful decisions in daily activities.

  • + 0 comments
    import java.util.*;
    
    interface commonDevison {
        int divisor(int n);
        
        
    }
    
    class calculator implements commonDevison{
        public int divisor(int n){
            int sum = 0;
            
            for(int i=1;i<=n;i++){
                if(n%i==0){
                    sum+=i;
                }
            }
            return sum;
        }
    }
    
    public class Solution {
    
        public static void main(String[] args) {
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
           Scanner input = new Scanner(System.in);
           int n = input.nextInt();
           
           commonDevison calculator = new calculator(); 
           System.out.println("I implemented: AdvancedArithmetic");
           System.out.println(calculator.divisor(n));
        }
    }