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 8945075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:10:04+00:00 2026-06-15T12:10:04+00:00

I want to solve this problem in Scala. My code: def dividers(n: Int) =

  • 0

I want to solve this problem in Scala.
My code:

def dividers(n: Int) =
  (1 until n) filter (x => n%x == 0)

def sumOfDividers(n: Int) = dividers(n).sum

val abNumbers = (1 to 28123) filter (x => sumOfDividers(x) > x)

The next step in my solutios is to make some sequence containing all possible of abundant number from abNumbers sequence. I’ve tried to do this with enhanced for loop, but it throws Java Heap Exception at runtime. How can i place all these sums into a Stream structure?

  • 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-15T12:10:05+00:00Added an answer on June 15, 2026 at 12:10 pm

    Use the toStream method on ranges:

    val abNumbers = ((1 to 28123) toStream).filter (x => sumOfDividers(x) > x)
    
    abNumbers: scala.collection.immutable.Stream[Int] = Stream(12, ?)
    

    Or am I missing something?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying for hours now to solve this problem.. So.. I want to use
I've been trying to solve this problem all day. I just want to list
I have a little problem: I want to solve this problem with OCaml, so
I am new to prolog and i want to solve this problem. Suppose I
I am trying to solve this problem myself but I can't. So I want
I followed other reslted question but still unable to solve this problem. I want
I want to solve this issue in query @ for Ex : id ip
I've been searching for days to solve this, but with no success. I want
I want to solve the following optimization problem: Non-Latex: Given x and mu, find
I have the following problem that I want to solve in awk. I have

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.