7 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for vegaseat

Just a couple of number tricks to check Go's mathematical abilities. If you have more, let's show them here.

Member Avatar for vegaseat
2
419
Member Avatar for vegaseat

Another translation of one of my Python snippets. This function will return a slice of consecutive prime numbers from 2 to a given value limit. In Go the 'int' type (int32) will go as high as 2147483647, but you can replace 'int' with 'uint64' and go as high as 18446744073709551615.

1
1K
Member Avatar for Michael27
Member Avatar for raj26061990

eg. 14 and 15 Find all the factors of 14 and 15. 1,2,7,14 are factors of 14 1,3,5,15 are factors of 15 Sum all the factors of two numbers and if sum of factors of two numbers taken are respectively equal they are Amicable numbers.

Member Avatar for cms271828
0
464
Member Avatar for TrustyTony

Roman numbers is a standard programming exercise, to give it a small twist, we input roman numeral, turn it to value and prepare minimal version of it using the substraction rule. Correctness of the input is not checked so Garbage in - Garbage out.

0
317
Member Avatar for avirag

This is a snippet that takes a min value, max value and how many random numbers from the user then, after it checks to make sure it's not already in the list, adds the new random number to a List.. I hope it helps you..... :)

Member Avatar for apegram
0
211
Member Avatar for Namibnat

[COLOR="Red"]Note two things: First off, I don't guarantee that it works well. Writing to files, if done wrong can always break things. Be careful. I mostly participate in this forum (the Python part) for fun, and my code is written like that. Second: this script is about copying things. I …

Member Avatar for Namibnat
1
768

The End.