Write a function primefactorization(n) that returns a list that represents a complete factorization of n into primes.For example primfactorization(24)=[2,2,2,3] .Test your function on n=2 through 100.
IN JAVA !!
import java.util.ArrayList;
public class PrimeFactors {
public static void main(String[]args)
{
System.out.println("*** PRIME FACTORS BETWEEN 2 AND 100
***\n"
+ "---------------------------------------");
for(int i = 2; i <= 100; i++)
{
if(getPrimeFactors(i).isEmpty())
System.out.println(i + ": No Factors");
else
System.out.println(i + ": " + getPrimeFactors(i));
}
System.out.println();
}
public static ArrayList<Integer> getPrimeFactors(int n)
{
ArrayList<Integer> factors = new ArrayList<>();
for(int i = 2; i < n; i++)
{
while(n % i == 0)
{
factors.add(i);
n /= i;
}
}
if(n > 2)
factors.add(n);
return factors;
}
}
************************************************************************ SCREENSHOT ***************************************************
Write a function primefactorization(n) that returns a list that represents a complete factorization of n into...
Write a Scheme function DEL-LELEMENT that takes a list as a parameter and returns a list identical to the parameter except the last element has been deleted. For example, (DEL-LELEMENT '(8 2 3 7 6)) should return (8 2 3 7) *Please explain your code and submit the source code. Please test the function with the provided example and submit a screen shot of the testing result.
Write a function findEvens that takes an integer, n, as input and returns the list of even integers between 1 and n. Ex. Input: 10 Output: [2,4,6,8,10] Write a function sortList that takes in a list of strings and returns a list of those strings now sorted and lowercase. Ex. Input: [‘ABE’,’CAD’,’gaB’] Output: [‘abe’,’acd’,’abg’] Both done in Python
Write a function which takes a list and returns frequencies of each element in the list? For example: L=[‘a’,’b’,’a’,’c’,’d’,’b’] Returns ‘a’: 2, ‘b’: 2, ‘c’: 1, ‘d’: 1
IN PYTHON: Write a function that takes, as an argument, a positive integer n, and returns a LIST consisting of all of the digits of n (as integers) in the same order. Name this function intToList(n). For example, intToList(123) should return the list [1,2,3].
In python Programming Exercise 1 Write a function that will have a list as an input, the task of the function is to check if all the elements in the list are unique,( i.e. no repetition of any value has occurred in the list), then the function returns true otherwise it returns false. Your program should include a main method that call the method to test it. Algorithm Analysis For the function you implemented in part 1, please calculate T(n),...
1. Question: Write a function that takes a list L and returns a random sublist of size N of that list. Assume that the indexes must be in increasing order. That is, you cannot go backwards Example L [1, 2, 3, 4, 5] 5 The function should return one of these lists: [2, 3, 4] [2, 3, 5] [2, 4, 5] [3, 4, 5]
Using Python Programming Language: 3. Write a function flatten that takes a 2D list and returns all the items of each list concatenated together into one new 1D list. For example: flatten ([["a", "b"],["c","0"],["e","f"]]) would return ["a", "b","C","d", "e","f"] Save the function in a PyDev library module named functions.py Write a program t03.py that tests flatten function and prints the returned flat list to the screen. Test your program with a different list, hardcoded in t03.py • Copy the results...
Write a Java application that asks for an integer and returns its factorization into prime factors including their powers. The prime factors must appear in increasing order. For example if 120 (= 2*2*2*3*5) in the input number, then your program should output 120 = 2^3 * 3^1 * 5^1 The factors should appear in increasing order and should be separated from each other by asterisks (*).
In PYTHON: Write a function that receives a list of integers and returns the number of integers that are larger than the element immediately before them. For example, given [1,2,3,-5,0,-5,-10] the function should return 3 (since 1<2, 2<3, and -5<0).
Write a Python function that creates and returns a list of prime numbers between 2 and N, inclusive, sorted in increasing order. A prime number is a number that is divisible only by 1 and itself. This function takes in an integer and returns a list of integers.