Draft

Prime or not. [Hard mode] JK

10 of 20Madrobot

Description:

NOTE FOR JS USERS:

the function called basics is just for testing and serves no purpose , don't try calling it , unless you wish to waste bytes.. your code goes inside the `P` function.

Challenge :

Given an array of numbers in the range of 0 to Infinity , Check whether all of them are primes or not.


Input :

An array of numbers


Output :

The array with every element replaced by one of these :

-1     -----> if 0 , 1
1      -----> If it is a prime number greater than 1
the highest factor -----> if that number is not prime

Return either -1 (0 , 1) , 1 (for primes >= 2) or the highest factor of given number (for non-primes)


Examples :

[1 , 2 , 3 , 4 , 10 , 11 ,13]                        ---> [ -1, 1, 1, 2, 5, 1, 1 ]
[100 , 200 , 231321 , 12312 , 0 , 111381209 , 123123] ---> [ 50, 100, 77107, 6156, -1, 1, 41041 ]

Note :

Input will always be valid. i.e : It will consist only of numbers and decimals are not tested for. The array can be empty return the empty array if that is the casess


Restriction :

1).This is code-golf so char limits :

JavaScript : Less than or equal to 45 (Still hellishly large if you ask me. Will probably reduce to 40 or lil less)

Python : Less than or equal to 65

2). No more than one line


Reason :

I am interested in seeing all sorts of solution and would like to see users beat my score (which a lot of people most definitely will)

Arrays
Mathematics

Stats:

CreatedMay 2, 2018
Warriors Trained132
Total Skips28
Total Code Submissions242
Total Times Completed20
JavaScript Completions10
Python Completions11
Total Stars0
% of votes with a positive feedback rating63% of 15
Total "Very Satisfied" Votes9
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes5
Total Rank Assessments13
Average Assessed Rank
4 kyu
Highest Assessed Rank
1 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • Madrobot Avatar
  • user8436785 Avatar
Ad