1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
KonstantinChe [14]
2 years ago
10

Write a function that accepts a positive random number as a parameter and returns the sum of the random number's digits. Write a

program that generates random numbers until the sum of the random number's digits divides the random number without remainder. assembly language
Computers and Technology
1 answer:
Luba_88 [7]2 years ago
4 0

Answer:

Explanation:

The following Python program has a function called addDigits which takes a number as a parameter and returns the sum of the digits. Then the program creates a loop that keeps creating random numbers between 222 and 1000 and divides it by the value returned from the function addDigits. If the remainder is 0 is prints out a statement and breaks the loop, ending the program. The picture below shows the output of the program.

import random

def addDigits(num):

   sum = 0

   for x in str(num):

       sum += int(x)

   return sum

sum = addDigits(random.randint(222, 1000))

while True:

   myRandomNum = random.randint(2, 99)

   if (sum % myRandomNum) == 0:

       print("No remainder between: " + str(sum) + " and " + str(myRandomNum))

       break

You might be interested in
"how do we store information in long term memory?"
Andru [333]

Answer:

By saving it in the hard drive.

Hope I helped!

8 0
3 years ago
What is the first stage of perception
Zigmanuir [339]

If we do not attend to stimuli, then we cannot perceive stimuli; thus attention is a critical factor in the process of perception. Receiving and attending to stimuli is the first stage in perception. Once we collect stimulus information from the senses, we have to try to make sense of it. This is called organization.


8 0
2 years ago
Read 2 more answers
A major concern about ESP claims is that proponents explain both the positive and negative findings. By explaining the negative
4vir4ik [10]

Answer: Falsifiability

Explanation: Falsifiability is the term that is defined as the evaluation of any particular hypothesis or theory to be proven wrong .This feature gives the access that the theory can be tested and have more accurate claims .

The ESP(Extrasensory perception) theory  can also have feature of being falsifiable because the experiments and test lead to the issue that the negative effects of the theory are not certain which might occur due to simple observation of effects.

5 0
3 years ago
Why would a user want to compress a large file before sending it as an email attachment?
Afina-wow [57]

to reduce the file size of the attachment

7 0
2 years ago
Read 2 more answers
Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha. Wri
Alina [70]

Answer:

In Java:

public static  int[] inputArray(){

   Scanner input = new Scanner(System.in);

   int[] alpha = new int[20];

   for(int i = 0;i<20;i++){

       alpha[i] = input.nextInt();

   }

   return alpha;}

public static  int[] doubleArray(int [] alpha){

   int[] beta = new int[20];

   for(int i = 0;i<20;i++){

       beta[i] = 2 * alpha[i];

   }

   return beta;

}

public static int[] copyAlphaBeta(int [] alpha, int [] beta){

   int [] AlphaBeta = new  int[10];

   for(int i = 0;i<5;i++){

       AlphaBeta[i] = alpha[i];

   }

   int count = 5;

   for(int i = 15;i<20;i++){

       AlphaBeta[count] = beta[i];

       count++;

   }

   return AlphaBeta;

}

public static void printArray(int [] alpha){

   for(int i = 0;i<20;i++){

       System.out.print(alpha[i]+" ");

       if((i+1)%15 == 0){

           System.out.println(" ");

       }

   }

}

Explanation:

The inputArray is defined here

public static  int[] inputArray(){

   Scanner input = new Scanner(System.in);

This declares alpha array of 20 elements

   int[] alpha = new int[20];

The following iteration gets input from the user into the array

<em>    for(int i = 0;i<20;i++){</em>

<em>        alpha[i] = input.nextInt();</em>

<em>    }</em>

This returns the alpha array

   return alpha;}

The doubleArray is defined here. It takes the alpha array as its input parameter

public static  int[] doubleArray(int [] alpha){

This declares beta of 20 integers

   int[] beta = new int[20];

This populates beta by 2 * alpha[i]

<em>    for(int i = 0;i<20;i++){</em>

<em>        beta[i] = 2 * alpha[i];</em>

<em>    }</em>

This returns the alpha array

   return beta;}

The copyAlphaBeta array is defines here

public static int[] copyAlphaBeta(int [] alpha, int [] beta){

This declares AlphaBeta as 10 elements

   int [] AlphaBeta = new  int[10];

This populates the first 5 elements of AlphaBeta with the first 5 of alpha

<em>    for(int i = 0;i<5;i++){</em>

<em>        AlphaBeta[i] = alpha[i];</em>

<em>    }</em>

   int count = 5;

This populates the last 5 elements of AlphaBeta with the last 5 of beta

<em>    for(int i = 15;i<20;i++){</em>

<em>        AlphaBeta[count] = beta[i];</em>

<em>        count++;</em>

<em>    }</em>

This returns the AlphaBeta array

   return AlphaBeta;

}

The printArray is defined here. It takes the alpha array as its input parameter

public static void printArray(int [] alpha){

This iterates through alpha array

   for(int i = 0;i<20;i++){

This prints each element of the array

       System.out.print(alpha[i]+" ");

A new line is started after the 15th element

<em>        if((i+1)%15 == 0){</em>

<em>            System.out.println(" ");</em>

<em>        }</em>

   }

}

See attachment for complete program which includes the main

Download txt
4 0
2 years ago
Other questions:
  • After a robbery, what is the purpose of conducting a neighborhood canvass?
    9·1 answer
  • The ________ occurs when the user presses the enter key without typing a value for an input operation.
    5·1 answer
  • Summarizes statistical data ?
    11·1 answer
  • Nathan wants to create multiple worksheet containing common formatting styles for his team members. Which file extension helps h
    9·1 answer
  • One common method of converting symbols into binary digits for computer processing is called ASCII​ (American Standard Code of I
    5·1 answer
  • Plato Web Tech B Semester Test- I'll mark brainiest for answers to ALL
    9·1 answer
  • what is musical technology specifically, the origins of its genesis &amp; its importance to the baroque era
    6·1 answer
  • How do I create a powershell script to make a Windows user account that is a non-admin user
    7·1 answer
  • write code that removes the first and last elements from a list stored in a variable named my_list. assume that the list has bee
    13·1 answer
  • Type the correct answer in the box. Spell all words correctly. Kenny is designing a document for the employee motivation campaig
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!