Want to get involved? We're always looking for ideas and content for Weekly Challenges.
SUBMIT YOUR IDEAany day that involves macros is a good day.
My solution was very similar to @PhilipMannering @EmanueleE @lminors
Maths is not my strong point so I went for the brute force approach and check a wide range of numbers until the closest prime was found!
Hm i am somewhat happy with my solution. Does anyone know if i am equating an iterative macro to a for/while-loop, is there an equivalent to a break?
Runs fast enough that despite its shortcomings im not too disappointed.
I wasn't sure where to start with this one, and since I've never had a chance to use the R tool I thought I'd attempt to replicate @JoeM's.
I used the same code from Stack Overflow except with the prime function written out as an IF THEN ELSE which was more intuitive to me. Probably less efficient but definitely easier to read.
I'll definitely be exploring the R tool more. I think I've just had my eyes opened to how many possibilities this opens up! Can't wait for a similar Python tool.
I half-solved this challenge a while ago, had only to update it slightly today.
Initially I build a workflow that checks if the number is prime or not so now I had only update it to be an iterative macro. In fact I built two macro, one that adds one to the initial entered number and the other that subtract from it.
The macro finds a square root of the entered number and then generate rows for all odd factors. Then I check the mod of a number, and transform all that equal zero to nulls. Then in summarise tool I find the the count of null mods, and if it is 0 then this is a prime number. A bit of a brute-force approach, I guess it could be a bit optimised by checking at the start if the number is even or not, so we can skip the whole stage of generating rows.