# Euler problems/181 to 190

From HaskellWiki

< Euler problems

Revision as of 23:09, 23 February 2008 by Daniel.is.fischer (talk | contribs)

## Problem 181

Investigating in how many ways objects of two different colours can be grouped.

Solution: This was my code, published here without my permission nor any attribution, shame on whoever put it here. Daniel.is.fischer

## Problem 182

RSA encryption.

Solution:

```
fun a1 b1 =
sum [ e |
e <- [2..a*b-1],
gcd e (a*b) == 1,
gcd (e-1) a == 2,
gcd (e-1) b == 2
]
where
a=a1-1
b=b1-1
problem_182=fun 1009 3643
```

## Problem 183

Maximum product of parts.

Solution:

```
pmax x a=a*(log x-log a)
tofloat x=encodeFloat x 0
fun x=
div n1 $gcd n1 x
where
e=exp 1
n=floor(fromInteger x/e)
n1=snd.maximum$[(b,a)|a<-[n..n+1],let b=pmax (tofloat x) (tofloat a)]
n `splitWith` p = doSplitWith 0 n
where doSplitWith s t
| p `divides` t = doSplitWith (s+1) (t `div` p)
| otherwise = (s, t)
d `divides` n = n `mod` d == 0
funD x
|is25 k=(-x)
|otherwise =x
where
k=fun x
is25 x
|s==1=True
|otherwise=False
where
s=snd(splitWith (snd (splitWith x 2)) 5)
problem_183 =sum[funD a|a<- [5..10000]]
```